Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12

Thread: PHP map

  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Question PHP map

    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?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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).

  • #3
    New Coder
    Join Date
    Jan 2012
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post
    rpg map:]

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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?

  • #5
    New Coder
    Join Date
    Jan 2012
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post
    yes it is
    this is what i whant - http://up.yop.lt/koor_map/map.php

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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)?

  • #7
    New Coder
    Join Date
    Jan 2012
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post
    i have all players coordinates, but map ... oh its... ;D i need just a map.. :] well i would better go to read the manual..:]

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Wait ...
    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 ?


    EDIT:
    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.


    .

  • #9
    New Coder
    Join Date
    Jan 2012
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post
    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?

    PHP Code:
    $a1=$y-1;
    $a2=$y-2;



    $b1=$y+1;
    $b2=$y+2;

    $c1=$x-1;
    $c2=$x-2;


    $d1=$x+1;
    $d2=$x+2;


    $e="$x;$a1";
    $e1="$x;$a2";
    $e2="$d1;$b2";
    $e3="$d1;$b1";
    $e4="$d1;$y";
    $e5="$d1;$a1";
    $e6="$d1;$a2";
    $e7="$d2;$b2";
    $e8="$d2;$b1";
    $e9="$d2;$y";
    $e10="$d2;$a1";
    $e11="$d2;$a2";


    $e13="$x;$b1";
    $e14="$x;$b2";
    $e15="$c1;$a2";
    $e16="$c1;$a1";
    $e17="$c1;$y";
    $e18="$c1;$b1";

    $e19="$c1;$b2";
    $e20="$c2;$a2";
    $e21="$c2;$a1";
    $e22="$c2;$y";
    $e23="$c2;$b1";
    $e24="$c2;$b2";



    $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")
    ); 
    Last edited by CompletelyGREEN; 01-31-2012 at 10:55 AM.

  • #10
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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.


    .

  • #11
    New Coder
    Join Date
    Jan 2012
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post
    no no no:] in the middle are coordinates which i get its x and y, and it is just village coordinates:]] nobody is moving:]

  • #12
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    sorry ...
    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).

    Example,
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •