Jump to content
  • Advertisement
Sign in to follow this  
MasterDario

Tactical Battle Engine Movement Help...

This topic is 4875 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a question about a problem im having with my 2d tactical battle engine, and that deals with movement. If anyone here has ever played shining force or pretty much any other tactical rpg, you know that whenever its someones turn and you select movement option all the squares of where you can move highlight, so that if the player had a movement stat of 4 for example he could move 4 squares up,left,down,right and 2 squares upleft,upright,downleft and downright. The problem im having is how would i add in terrain reductions and inpassable tiles. So that if there is grass to the right of a character the movement is cut in half or if there is a wall to the left of the character he cant move in that direction at all? Also what would be the best way to display these tiles? Any help is appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Since you're in 2D, it should be easy for you to split up the terrain in a grid.

Each node in the grid should have a "movement cost", and have exceptionnal costs for "totally blocking", like a wall.

The way I did it in a very simple demo was to have an algorithm similar to Djikstra's iterate through the nodes around me as long as I would have movement points to reach them. By storing in each selected node its "cheapest parent", its pretty easy to backtrack and to be sure to have the most optimal path.

If you want my source code, I might have it somewhere at home, drop me an email.

By the way, what you're trying to achieve is pretty similar to pathfinding, so check out sites like James Matthews' Generation 5, and be sure to check out his A* explorer.

Just to clear things out, A* is usually used to get from a specific node to another specific node, while Djikstra is usually used to find the "easiest to reach" node of a specific type. In my example, I used Djikstra to find *all* the reachable nodes.

Hope this helps

Eric

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!