Page 1 of 1

Draggable Game Map?

Posted: Mon Mar 24, 2014 6:01 pm
by Klown
Anyone seen any sort of tutorials on a draggable game map similar to those flash games like Evony, Kingdom of Camelot - where the game world is a grid system, usually isometric 2d, and to move around you just click and drag instead of using a button to move arrows in each direction?

The map I am trying to refine is loaded on a grid of divs from a mysql database - I just cannot seem to find any resources on google/youtube anywhere that give a hint of this type of technique and the members here always have the answers!

Thanks!

Re: Draggable Game Map?

Posted: Tue Mar 25, 2014 9:01 am
by Winawer
I've used jQuery UI draggable (http://jqueryui.com/draggable/) in the past for some prototypes of draggable game maps. It was pretty simple in my experience, but I'm not sure if it suits your requirements, you'll have to test it for yourself.

Re: Draggable Game Map?

Posted: Tue Mar 25, 2014 9:29 am
by Chris
This effect is easy to achieve. The problem is how the browser renders the divs. Too many and your page becomes unusable even on the fastest machines. If this becomes a problem you'll need to look into canvas.

Re: Draggable Game Map?

Posted: Tue Mar 25, 2014 10:02 am
by Winawer
You could also lazy unload the divs when they're no longer in view.

Re: Draggable Game Map?

Posted: Tue Apr 01, 2014 1:52 pm
by hallsofvallhalla
canvas ftw

Re: Draggable Game Map?

Posted: Tue Apr 01, 2014 9:35 pm
by Jackolantern
Winawer wrote:You could also lazy unload the divs when they're no longer in view.
This is what Google Maps does, or at least used to do when the world was amazed by Google maps lol. When you scroll, it cleverly loads more grid cells of the map out of view by AJAX so they are ready when you scroll them into view (provided you aren't scrolling like a mad man), and then as you move away from a grid cell that is out of view, it unloads them.

If it didn't do this, Google Maps would grind to a halt after a few minutes of scrolling around.

Re: Draggable Game Map?

Posted: Thu Apr 03, 2014 10:22 am
by Chris
Jackolantern wrote:
Winawer wrote:You could also lazy unload the divs when they're no longer in view.
This is what Google Maps does, or at least used to do when the world was amazed by Google maps lol. When you scroll, it cleverly loads more grid cells of the map out of view by AJAX so they are ready when you scroll them into view (provided you aren't scrolling like a mad man), and then as you move away from a grid cell that is out of view, it unloads them.

If it didn't do this, Google Maps would grind to a halt after a few minutes of scrolling around.
I'm making it :D