Page 1 of 1

Walkable map

Posted: Tue Oct 30, 2012 6:13 am
by Torax
*

Re: Walkable map

Posted: Tue Oct 30, 2012 6:40 am
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

Re: Walkable map

Posted: Tue Oct 30, 2012 6:46 am
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 :)

Re: Walkable map

Posted: Tue Oct 30, 2012 7:05 am
by Torax
*

Re: Walkable map

Posted: Tue Oct 30, 2012 7:12 am
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!

Re: Walkable map

Posted: Tue Oct 30, 2012 7:20 am
by Torax
*

Re: Walkable map

Posted: Wed Oct 31, 2012 5:53 pm
by hallsofvallhalla
that is the way I did it in Forsaken Sanctum, just check out the source.

Re: Walkable map

Posted: Wed Oct 31, 2012 10:51 pm
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 :)

Re: Walkable map

Posted: Thu Nov 01, 2012 6:49 am
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.

Re: Walkable map

Posted: Thu Nov 01, 2012 11:18 am
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.