Map design, how?

C++, C#, Java, PHP, ect...
Post Reply
RolsenRoyce
Posts: 24
Joined: Tue Oct 20, 2009 3:00 pm

Map design, how?

Post by RolsenRoyce »

I have been googling on how to make a map like this:
Image

Now, some dude pasted code:

Code: Select all

<?php

set_time_limit(10800);

    for($y=40;$y>=1;$y--)
    {
        for($x=1;$x<=40;$x++)
        {
            require_once('includes/db/DbConnector.php');
            $connector = new DbConnector();
            $result = $connector->query('SELECT * FROM harta WHERE x = "'.$x.'" AND y = "'.$y.'" ');
            while($row = $connector->fetchArray($result))

            echo '<img src="images/harta/lan_'.$row['tip'].$row['subtip'].'.gif" title="('.$row['x'].'|'.$row['y'].')" style="float: left;margin: 0;padding:0;">';
        }
    }

?>

Code: Select all

<?php

set_time_limit(10800);

    if(!$_POST)
    {
    for($y=40;$y>=34;$y--)
    {
        for($x=1;$x<=7;$x++)
        {
            require_once('includes/db/DbConnector.php');
            $connector = new DbConnector();
            $result = $connector->query('SELECT * FROM harta WHERE x = "'.$x.'" AND y = "'.$y.'" ');
            while($row = $connector->fetchArray($result))

            echo '<img src="images/harta/lan_'.$row['tip'].$row['subtip'].'.gif" style="float: left;margin: 0;padding:0;">';
        }
    }

    echo '<div style="margin-top: 380px;">';
        echo '<form method="POST" action="hartamica.php">';
        echo 'x: <input type="text" style="width:50px;" name="x"><br>';
        echo 'y: <input type="text" style="width:50px;" name="y"><br>';
        echo '<input type="submit" name="submit" value="Cauta!"><br>';
        echo '</form>';
    echo '</div>';

    }
    else
    {
    $cx = $_POST['x'];
    $cy = $_POST['y'];

    $cy1 = $cy+3;
    $cx1 = $cx-3;

    $cy2 = $cy-3;
    $cx2 = $cx+3;

    for($y=$cy1;$y>=$cy2;$y--)
    {
        for($x=$cx1;$x<=$cx2;$x++)
        {
            require_once('includes/db/DbConnector.php');
            $connector = new DbConnector();
            $result = $connector->query('SELECT * FROM harta WHERE x = "'.$x.'" AND y = "'.$y.'" ');
            while($row = $connector->fetchArray($result))

            echo '<img src="images/harta/lan_'.$row['tip'].$row['subtip'].'.gif" title="('.$row['x'].'|'.$row['y'].')" style="float: left;margin: 0;padding:0;">';
        }
    }

    echo '<div style="margin-top: 380px;">';
        echo '<form method="POST" action="hartamica.php">';
        echo 'x: <input type="text" style="width:50px;" name="x" value="'.$_POST['x'].'"><br>';
        echo 'y: <input type="text" style="width:50px;" name="y" value="'.$_POST['y'].'"><br>';
        echo '<input type="submit" name="submit" value="Cauta!"><br>';
        echo '</form>';
    echo '</div>';
    }

?>
I would like to use the code, but I have no idea how it works.
I do not know why there are two codes either.

So, I wondered if someone could take some time to explain this valuable code to the rest of us?

Source: http://www.dreamincode.net/forums/showtopic76140.htm
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: Map design, how?

Post by hallsofvallhalla »

moved topic out of browser tutorial...


Well this is the basic build code of the design. Still seems like it is missing a few things but just throw it on a test page and make sure you have the image files where it looks for them at. You can remove the connector crap and include your own connect.php
User avatar
MAruz
Posts: 117
Joined: Fri Nov 20, 2009 12:31 pm

Re: Map design, how?

Post by MAruz »

Hm, nice find! I haven't got the energy to look much into this now, but I'll do tomorrow! :) Dunno if I can help you or not, but I'm looking into using something like this for my own project so I hope I can get something out of it.
PHP, Java, JavaScript, HTML, CSS, XML, MySQL / Oracle
Photoshop, Illustrator
www.cuddly-zombie.com
jpoisson
Posts: 245
Joined: Sun Aug 02, 2009 5:12 pm

Re: Map design, how?

Post by jpoisson »

I cheated when I created my map. Unfortunetly It is all done by hand :P but it is less then 50 lines of code :P
Laguages:
PHP, MYSQL, (X)HTML, HTML5, JQuery, CSS 3.0,
C, C#, C++, Python, Pascal, Perl, Ruby, Turing

Software:
Adobe MC CS4, Visual Studio 2008, Notepad++,
NetBeans IDE, WAMPSERVER

Browsers:
Internet Explorer, Firefox, Opera, Safari, Chrome
(Always have latest patches for browsers.)

Free time:
...
Post Reply

Return to “Coding”