Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advanced RPG-Style Movement in XNA [closed]

Tags:

xna

I am making a top down, rpg-type game - similar to Pokemon, but I am stuck at character movement. Basically, what I want to achieve is a smooth tile based movement system for my player and other people on the map. Has anyone managed to do this effectively? If so, how?

like image 425
Xedfire Avatar asked Dec 21 '22 15:12

Xedfire


1 Answers

If you are using a grid system, like Pokémon uses, you might be able to achieve this by setting a speed at which they can move between tiles.

For example, if you made it so that they can move one tile a second, you can then use (float)gameTime.ElapsedGameTime.TotalSeconds in your Update function to determine how quickly the game is updating. From this, you should be able to make it so that the character moves ((float)gameTime.ElapsedGameTime.TotalSeconds * TileSize) each update.

This would mean that if they have 4 updates a second (very slow, but for example), they would move 1/4 of the distance across the tile every update, and reach the end point by the end of the movement time period (1 second in this case). In this situation, if you had 32 pixel tiles, they would move 0.25 * 32 every update, or 8 pixels.

Hope this helps.

like image 181
Lyise Avatar answered Dec 30 '22 11:12

Lyise