Well done! Thank you for your lessons and efforts! I wish prosperity to your channel :D
@abdulrazaqAS5 ай бұрын
I have downloaded your repo, thanks for all the stuff. I have placed and animated the knife dude. He moves back and forth within a defined range and can throw knives when in range. I have also implemented the batarang attack. I also coded a sprite scraper file to help me get the parameters of sprites in a spritesheet file. I will fork the repo and upload my added stuffs.
@isuckatmc17287 ай бұрын
i dont understand, do you actually move eeach entity? but then you wouldnt need to move the player as well when walking, right? or do you just move the display position of your sprites but not their actual position? but then, how does collision detection still works? im so confused😅
@hucorp7 ай бұрын
You're on the right track! I think that I could have explained this better in the video, but yes the player is moving while walking. Think of the camera as a rectangle that displays what is on the window. When the player moves right, we're moving this rectangle around it right as well. We have a map that is bigger than the window and we want the camera to cover all the pixels in the map. When every sprite is created they are assigned a (x, y) position on this map; we don't want to change the position of every tile in the map. Whatever's at (0, 0) on the map, should stay at (0, 0) on the map. The camera only affects what parts of the map are DRAWN on the screen. However, the camera's (0, 0) is going to be changing as we move right. As the camera moves right, we want the map to be DRAWN with an offset by the same amount that the player moved. So if the player started at (0,0) and moved 10 pixels to the right, their new position is going to be (10, 0). And whatever is on (10, 0) of the map is now going to be displayed as (0, 0) on the camera. Likewise, if we have an obstacle that is positioned at (20, 0) on the map, it's going to be drawn on the camera at (10,0) when the player moved 10 pixels to the right. It's like having two frames of reference: one is the map's pov which is the actual position and the other is the camera's. The map's (0, 0) is always defined and it's fixed, but the camera's (0,0) is shifted as the player moves.