Jump to content
  • Advertisement
Sign in to follow this  

[web] Tilemap pathfinding

This topic is 2944 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


So i'm "done" with my map for my mmo space sim. Well at least you can look around and fly around. However flying still happens instant where it should take time to fly to another tile.

Now i'm looking for a way to to create a pathfinding script. So when the player chooses to fly a couple of tiles he travels he should travel 1 tile every couple of seconds and has the option to stop. Anyway i just like some thoughts on how i should approach this and what problems i might encounter.

Now since there is no collision i think i know how to do that by checking how much tiles it goes in X and how much tiles in Y and go diagonal for the lowest number till it reaches that line and further on go straight.

Each time the location shifts by one tile the DB should get updated so other players can see this ship incoming. A problem could be if the player leaves the map window (for example to check some other things while he is flying). Since on another page there is no script for the pathfining and neither a script for canceling the flight. I would like the player to continue flying while he for example checks his stats or finances. How would i approach this best?

1. I could make a script for each page the player has acces too during flight. Do a check if the player is flying and if so start the flight script.

2. since i load every info screen in the main content div with Jquery (where the map is located too) i can put the script on the main page. Since this page isn't reloaded i should constantly poll the DB if the player is in flight and since fast ships take just a second to fly 1 tile i need to poll a lot for each player wich can overload the DB.


Your thoughts plz...

Share this post

Link to post
Share on other sites
Well, i guess that was a VERY stupid question as i figured it all out in a couple of hours :D.

What i did:

Created an extra div in the document. And when player clicks a tile and chooses to fly the div gets loaded with a PHP file that checks if a new location is given and where it leads. Did some if statements to pinpoint the direction and update the DB if destination is not reached.

Then the php echoes a script to delay this relatively by ships speed and the loads PHP script again in the specific div. Obviously now the database is one step ahead of the players view because the php code runs first and then the script is loaded. So i sent a variable with to the script and when thats set correctly the DB will update.

Any further thoughts? I think i can easily create collision too if i should need it.

Anyway, The game really comes together now, theres just a some programming to do to have something interesting to do :D. But it's not finished by a long shot really :D.

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!