#30944 - identitycrisisuk - Mon Dec 06, 2004 3:16 pm
This is kinda something you have to see so if anyone doesn't mind going here and downloading test.zip it'd be much appreciated. Basically what happens is when you've been walking for a little while and stop or if you turn around and the screen has room to move, the sprite for my guy kinda looks like he's sliding on the floor. It's only a few pixels, it's just about noticable on hardware and easier to see with an emulator, I think it's something to do with me creating the position and it being used on the next frame not that one or vice versa. This is the basics of my main loop:
Player Update takes care of the collision detection and works out where the player is in the world at that point in time. The Background Update then takes in the Players position to work out where the top left corner of the screen is, does some things to make it move smoothly and updates any BG tiles that need it. I've called the next function draw but it's really just putting the correct data in to the OAM entries array, it works out the onscreen position of the sprite by doing: Character world position - Top left position of screen in world.
Then you've got the vsync thing, not a real function, just a macro for while(REG_VCOUNT != 160). Then copying of the OAM data and after that a function to copy the appropriate frames of the character to VRAM if a change in animation has taken place. I put this here as I was having some problems with when the frame would actually be loaded if it was before Vsync. Just reading back through what I've written it's becoming clearer that it must be something to do with the backgrounds being updated instantly but the sprites are done the frame after. I'm just not quite sure of how to rearrange my loop, is there a guide anywhere as to what you should do before and after the vsync check? Sorry if I've already got some things in stupid places, I've just been following the tutorials I looked at.
_________________
Code: |
Player.Update();
Background.Update(Player.Pos(), Player.Dir()); Player.Draw(Background.Pos(), &sprites[0], &sprites[1]); vsync(); CopyOAM(); //Copies sprite array into OAM. Player.UpdateFrames(); |
Player Update takes care of the collision detection and works out where the player is in the world at that point in time. The Background Update then takes in the Players position to work out where the top left corner of the screen is, does some things to make it move smoothly and updates any BG tiles that need it. I've called the next function draw but it's really just putting the correct data in to the OAM entries array, it works out the onscreen position of the sprite by doing: Character world position - Top left position of screen in world.
Then you've got the vsync thing, not a real function, just a macro for while(REG_VCOUNT != 160). Then copying of the OAM data and after that a function to copy the appropriate frames of the character to VRAM if a change in animation has taken place. I put this here as I was having some problems with when the frame would actually be loaded if it was before Vsync. Just reading back through what I've written it's becoming clearer that it must be something to do with the backgrounds being updated instantly but the sprites are done the frame after. I'm just not quite sure of how to rearrange my loop, is there a guide anywhere as to what you should do before and after the vsync check? Sorry if I've already got some things in stupid places, I've just been following the tutorials I looked at.
_________________
Code: |
CanIKickIt(YES_YOU_CAN); |