As usual I have been away for a while and now that I have some free time I have been tinkering with my game. However I am at a loss as to what is going on with my events and update/redraw (The game is a top-down adventure game like Zelda)
My game loop boils down to the following:
Which as far as I can see is the same as what other discussions have suggested as a game loop (not just here on this forum). Now I run the animation at 60 FPS and the logic at 120 'clicks' per second (the animTimer and logicTimer respectively).
However, and this is the problem: quite frequently the game 'jumps'. What happens is my character is walking along in a room and then suddenly ends up across the other side of the room in the direction he was walking collided with the wall. It is as if his speed has suddenly gone through the roof. This also affects enemies too. Now I know that the logic 'ticks' are constant as is the redraw timer's, as well as the character's speed (as I print these on the screen for debugging). I also know that even if I reduce the logic updates to 10 times a second I still get the same effect!
The only thing I can think is that the game is updating far more often than it should. I know this because when I print a counter of the number of updates it runs OK when everything is fine, but runs really quickly when I see these jumps.
What can cause the game to speed up so quickly all of a sudden? Is there a glaring error in my code or something I missed? Any help would be appreciated!