![]() The tiles are 16x16 in-game, as stated before, and you have two of these open before the third, which is blocked. So the question I ask is essentially "if this moves X amount of pixels to direction Y now, will my collision box be touching a blocked tile? But if you're moving 5px at a time, this eventually causes a very obvious issue. I read the positions back as integers, though, since I'm working with pixels. The positions are stored as double points, so on that level, this is fine. This works fine if you're working with 8px as the global movement speed, but I'd like to treat 8px as "100% speed" and have complete control over character speed with a double that is in the range [0,1). ![]() This rectangle is essentially 16x16 in-game, and is in the center of the character, which allows for the overlap necessary. Where the position is an (x,y) point, the Rectangle is a box surrounding that point. To deal with this set of problems, I created an invisible Rectangle and attached it to the character's position. Since the character tiles are bigger than the map tiles, the map is built in a way that requires the characters being able to "overlap" onto blocked tiles. I store positions as the center point of each character. ![]() In actuality, they are all pulled from a spritesheet of 8x8 tiles. In-game, the map tiles are treated as 16x16, and the characters (Pacman and the ghosts) are treated as 32x32. I am programming a 2D, grid-based Pacman game. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |