Draggable Game Map?

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
Klown
Posts: 90
Joined: Tue Feb 22, 2011 5:59 am

Draggable Game Map?

Post 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!
if( $myGames != "Crap" ) {
  • please_donate( $money );
} else {
  • just_enjoy();
}
Winawer
Posts: 180
Joined: Wed Aug 17, 2011 5:53 am

Re: Draggable Game Map?

Post 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.
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: Draggable Game Map?

Post 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.
Fighting for peace is declaring war on war. If you want peace be peaceful.
Winawer
Posts: 180
Joined: Wed Aug 17, 2011 5:53 am

Re: Draggable Game Map?

Post by Winawer »

You could also lazy unload the divs when they're no longer in view.
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: Draggable Game Map?

Post by hallsofvallhalla »

canvas ftw
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: Draggable Game Map?

Post 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.
The indelible lord of tl;dr
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: Draggable Game Map?

Post 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
Fighting for peace is declaring war on war. If you want peace be peaceful.
Post Reply

Return to “Advanced Help and Support”