I’m working on an incredibly simple snake-game in C# using XNA. The problem is that I want the sprite to move in increments but not as fast as possible. Since the sprite is 16×16 pixels, it moves in increments of 16 pixels. For example, if the current direction is right, this line executes:
playerPosition.X += 16;
This works beautifully, but it moves at an incredible speed. How would I go about to make it move slower? Like 16 pixels every 1/2 second.
It has been a long time since I last used XNA but from what I remember in the game loop when you are doing your actions you have access to a property which is essentially time elapsed since last action. You should use this and reduce your 16 pixel movement to only go as far as it would in that portion of the second.
Most of the time you can just divide by 60 and use that as your new movement speed and be pretty safe. so 16/60 for your per frame pixel movement if you want to move 16 pixels a second.