Jump to content


2D tiled SLG game


3 replies to this topic

#1 codetale

    New Member

  • Members
  • Pip
  • 3 posts

Posted 09 February 2007 - 04:41 PM

i am doing a 2D SLG game in tiled
and i was facing a moveable tile calculation problem.

i have fully implement tiled map, and store the tile height (Movement point required by each tile) in the map.

please refer to picture below, where 2, 3 specify the tile' required movement point(MP), where no specify are required 1 MP.
blue ball are the player(character) with 3 MP
red are moveable tile.
Posted Image
player have 3 movement points in this sample

my problem is how to obtain the moveable tile by giving character position(x, y) and MP?

#2 codetale

    New Member

  • Members
  • Pip
  • 3 posts

Posted 12 February 2007 - 04:36 AM

emm... nobody do this before?

or just give me some idea
or tell me what this algorithm called or technique/data structure are required, so that i can google

thankyou very much

#3 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 12 February 2007 - 05:50 AM

Google for Dijkstra's algorithm. Basically you want to set up a graph with grid squares as the nodes and edges going between adjacent grid squares. The edge weights will correspond to the movement points required. Then run Dijkstra's algorithm starting from the player position and find all the nodes with a distance of 3 or less.
reedbeta.com - developer blog, OpenGL demos, and other projects

#4 codetale

    New Member

  • Members
  • Pip
  • 3 posts

Posted 12 February 2007 - 11:54 PM

thank you, i think i get it





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users