Translating between the sprite's absolute coordinates and virtual tile coordinates is a simple function. For example:Īll maze objects, targets, exits, etc. In Pac-Man they are 8x8 pixels, but in my game they are only 4x4 pixels since sprites are 8x8. They are either open corridors or walls, just like in Pac-Man. Virtual tiles are the logical tiles in which sprites move and interact. Maze virtual tile - this is the effective tile in which the sprite is at any moment.Sprite absolute position - this is the (X, Y) coordinates of the sprite object on the screen, with the origin at the top-left corner of the screen.State - The state of the sprite (e.g., Moving, Rest, Dead, etc.)ĭirections are tracked in a 4-bit vector that tells whether the sprite is moving Up (N), Right (E), Down (S), or Left (W).Īlso, there are two coordinate systems to track:.DirNext - The next direction of travel, that is, the new direction the player pressed on the Joystick before it's accepted.DirCurr - The current (valid) direction of travel.It also updates the sprite's state to "moving," in case it was at rest. Otherwise, it keeps track of the new direction until the joystick is released. It checks whether there is an exit towards the new direction and updates the current direction of travel if there is. Second, the "update sprite direction" routine which runs when new input is detected.It uses a look-up table indexed by Pac-Man's position within his current tile. First, the normal "move sprite" routine that runs on every frame, which follows the direction of travel. My algorithm is implemented in two parts: My method is to use a look-up table for the movement deltas, rather than to just move in the direction of travel. Well, I know I have not written for a long time, I apologize for that, I'll try to be more active now. Soon I will be publishing a test version. With that change I made, it is much simpler to do the "cut corner", I am doing tests and I think it could work, although only advancing up to 2 pixels diagonally for now, the DZ-jay method is interesting, although I still don't know how It works, neither know if I can do something similar here. Hello, I'm working on this again and recently I've been making changes in the movement routine, now the objects are moving much faster, in the test I'm doing you can switch between normal and fast with the left difficulty switch.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |