View Full Version : PHP map
01-30-2012, 11:55 AM
Hey friends, maybe anyone could help me to solve my problem..
So, I want to make a map 2D map with X Y coordinates for example
X X X X X
X X X X X
X X o X X
X X X X X
X X X X X
o is my coordinate and it have to be centered .
please help, i know that coordinates must be in 2D array, but whats next?
01-30-2012, 01:23 PM
A map .. like a Google Map, or a map you made up yourself (RPG) ?
If it's your own map, you need to know how many cells or divisions there
are across (column) and down (rows), and how many pixels across (width)
and down (height).
01-30-2012, 01:54 PM
01-30-2012, 01:56 PM
So is each one of your cells a tiny image (like a PNG image).
and you put them all together to form a visual map?
01-30-2012, 02:08 PM
yes it is
this is what i whant - http://up.yop.lt/koor_map/map.php
01-30-2012, 02:12 PM
How much of it do you already have?
Or, are you starting from scratch and you don't have any scripting?
Do you even have a database (MySQL) for all of your players (profile, info)?
01-30-2012, 02:21 PM
i have all players coordinates, but map ... oh its... ;D i need just a map.. :] well i would better go to read the manual..:]
01-30-2012, 02:31 PM
You have some choices you need to make.
You can create your map with each cell being a part of your map.
Those images are each in a <div> with the cell image as the background.
You then place your player's avatar, or other item on top of the cell background.
Or, you can do like the map you showed, and each one is an actual image.
Tell us what your "system of operation" will be for how you organize your data.
Is everything by ROW/COL? How do you save each map cell image, with a
coordinate as the filename? R10-C13.png ?
Some people create a really nice graphical map using photoshop.
They then slice it up in to cells ... (500 X 500) and save each
cell as a coordinate. R1-C1.png, R1-C2.png ... etc.
01-31-2012, 11:07 AM
Hi its me again, i have a question , how i can do all of this automaticaly? for example if i want not 5x5map but 10x10? or 20x20? all that math,arrays and centering of x y coordinates?
$map = array(
array("$e11", "$e10", "$e9", "$e8","$e7"),
array("$e6", "$e5", "$e4", "$e3","$e2"),
array("$e1", "$e", "$x;$y", "$e13","$e14"),
array("$e15", "$e16", "$e17", "$e18","$e19"),
array("$e20", "$e21", "$e22", "$e23","$e24")
01-31-2012, 02:43 PM
You do linear line equations ...
Remember the stuff in algebra like y=mx+b ?
You need to know two points on your map (the coordinates X and Y).
And you need to know the scaling (in pixels) of your display box on the page.
After that, you can scale it, move it around, display or do anything you want.
You have not said how you will be setting-up your mapping system.
Do you have a database with each map coordinate as a row in the table?
What is your system? How do the coordinates relate to your map image,
and how do they relate to the players' positions. As I mentioned in post #8,
there is more than one way to arrange your database.
Pretend the player's name is "Xman" ...
He's moving around in your game.
You tell me how you know where he is and what coordinate system you use
to keep track of that. Describe how you know where Xman is. And when Xman
leaves your game and comes back two days later, how do you know where he
was at ... so he can continue the game?
Describe how Xman moves around, and how Xman relates to your graphical map.
01-31-2012, 04:19 PM
no no no:] in the middle are coordinates which i get its x and y, and it is just village coordinates:]] nobody is moving:]
01-31-2012, 04:59 PM
Now I'm confused again.
If you know the dimensions of your map,
and you have to place one of the map pieces
in the center, just by the coordinates of that
center piece, you'll know where to start drawing
the map in the upper left corner (where to place
the first piece).
If you tell me to place 34,46 in the center, and
your map is 20 X 20, I know that the upper
left corner must be:
34-10 ... 24
46-10 ... 36
So the upper left is 24,36 ...
That puts 34,36 in the center.
Is that what you mean?
I just don't follow this.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.