Walkable map

For discussions about game development that does not fit in any of the other topics.
Post Reply
Torax
Posts: 169
Joined: Sun May 13, 2012 2:38 pm

Walkable map

Post by Torax »

*
Last edited by Torax on Wed Jan 03, 2018 12:03 am, edited 1 time in total.
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Walkable map

Post by SpiritWebb »

You can try looking at this thread, when I was building my map a while ago, it might help or at least point you in the right direction:
viewtopic.php?f=29&t=4457
Image

Image
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Walkable map

Post by Jackolantern »

Are you actually wanting to animate the movement of the player character, or have it just be click a button and the character is moved? The latter is quite a bit easier. If I understand right, you want the player to stay centered in the middle of the screen, so basically you would just have the map move. You can basically do this in CSS. You would have the map area surrounded by a div with an id. For example, if the id is "map", you could play around with the "background" attribute, which has a handy extra feature that allows you to choose what part of a larger image to display:

Code: Select all

#map {
   width: 400px;
   height: 400px;
   background:url(myMap.png) 1100 460;
}
What is happening here is the "width" and "height" attributes correspond to how big the visible portion of your map is (how much you want to show at once). Then the "background" attribute is simply loading the myMap.png image into the background of your #map div, but instead of making the upper-left corner at (0, 0) like it normally would, the upper-left corner of the visible, on-screen map would be at (1100, 460) of the fictional large map image.

Then, when you wanted to move the character, you would just need to subtract or add however many pixels you want the player to move from the appropriate X or Y value (for north, you would add to Y, or the 460 above, or for west you would subtract from X, the 1100 for example). Then you just add the player image to the center of the map by using absolute positioning inside the #map div.

If you did want to actually animate it, it would be a bit more involved but you could still use the same technique. You would just use Javascript to animate the player image and change the "background" attribute X and Y values a little bit in each frame until they get to their destination :)
The indelible lord of tl;dr
Torax
Posts: 169
Joined: Sun May 13, 2012 2:38 pm

Re: Walkable map

Post by Torax »

*
Last edited by Torax on Wed Jan 03, 2018 12:03 am, edited 1 time in total.
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: Walkable map

Post by SpiritWebb »

Mine is done as a separate image per tile, and updated each time a directional arrow is pressed.

The image name, coords (X, Y) and image location are stored in the database, not the image itself. The PHP does the rest!
Image

Image
Torax
Posts: 169
Joined: Sun May 13, 2012 2:38 pm

Re: Walkable map

Post by Torax »

*
Last edited by Torax on Wed Jan 03, 2018 12:03 am, edited 1 time in total.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Walkable map

Post by hallsofvallhalla »

that is the way I did it in Forsaken Sanctum, just check out the source.
Torax
Posts: 169
Joined: Sun May 13, 2012 2:38 pm

Re: Walkable map

Post by Torax »

hallsofvallhalla wrote:that is the way I did it in Forsaken Sanctum, just check out the source.
Awesome I'll have a look at it. Thanks :)
Torax
Posts: 169
Joined: Sun May 13, 2012 2:38 pm

Re: Walkable map

Post by Torax »

Oroton wrote:So is this like a Pokemon walkin map that you can make? Is it a pbbg?
If so anyone got like an open source project I look at code wise??
What language is it used in if you can parse info through to a database
Thanks!
It all depends on how you code it, if you wanted and tried you could probably make an exact replica of the Pokemon map. Or similar to other RPGs.
Torax
Posts: 169
Joined: Sun May 13, 2012 2:38 pm

Re: Walkable map

Post by Torax »

Oroton wrote:Wow that's actually really awesome, what language would you use?
I haven't started my map yet, but I would use HTML and PHP, and I would have my coordinates stored into the MySQL database.
Post Reply

Return to “General Development”