I'm trying to create a tile based world map like Tribal Wars has or The-West games. I created a little bit of it but it loads too slow when you drag the map with your mouse.
My algorithm works like this:
On page load:
- load the tiles from 1 to 19(x1 to y1 and x2 to y2) via JQuery's $.post method(I need the screen's width and height for that 19=1900/tile_width, because I want the map to fill the entire page)
- append the returned data(tiles) to the screen (so far so good)
On map drag:
- load again via .post tiles (based on how many pixels you dragged)
- append again the data(tiles on the screen)
Everything is working if you drag slow but if you want to drag like a crazy man the map will become a mess(it doesn't load all the tiles)
Can you provide me a better algorithm with some examples if possible or maybe some source codes (i didn't found nothing on google about these 2 games' maps)
P.S. I tried to put my example on 000webhost.com but I don't know why the json_decode()
returns null
.On my pc works fine.