Walkable map
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: Walkable map
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
viewtopic.php?f=29&t=4457
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Walkable map
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:
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
Code: Select all
#map {
width: 400px;
height: 400px;
background:url(myMap.png) 1100 460;
}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
- SpiritWebb
- Posts: 3107
- Joined: Sun Jul 12, 2009 11:25 pm
Re: Walkable map
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!
The image name, coords (X, Y) and image location are stored in the database, not the image itself. The PHP does the rest!
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Walkable map
that is the way I did it in Forsaken Sanctum, just check out the source.
Re: Walkable map
Awesome I'll have a look at it. Thankshallsofvallhalla wrote:that is the way I did it in Forsaken Sanctum, just check out the source.
Re: Walkable map
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.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!
Re: Walkable map
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.Oroton wrote:Wow that's actually really awesome, what language would you use?

