3Q man?devana Open Source?Reference to the map production method ,PHP+MYSQL?no css and JS)
Effect Picture?7*7 grid
If you want to move target in this map,Giving target coordinates can be done?Do provide an idea? ;)
index.php
<?php include "antet.php"; include "func.php";
if (isset($_POST["x"], $_POST["y"])) {$x=clean($_POST["x"]); $y=clean($_POST["y"]);}
else {$x=rand(0, $m); $y=rand(0, $n);}
$data=map($x, $y);
$i=0;
?>
<div style="position:relative; top:0; left:0;">
<?php
for ($k = 6; $k >= -6; $k--)
{
for ($j = -6; $j <= 6; $j++)
{
$st_x = ($k + 6) * 40 + ($j + 6) * 40;
$st_y = (6 - $k) * 20 + ($j + 6) * 20;
?>
<img style='position:absolute;left:<?php echo $st_x; ?>px;top:<?php echo $st_y; ?>px;width:80px;height:80px;' <?php map_img($data, $x+$j, $y+$k, $i, $imgs); ?>>
<?php
}
}
?>
[img=<?php echo $imgs ?>map/map_back.gif]
<?php
$i = 0;
for ($k = 6; $k >= -6; $k--)
{
for ($j = -6; $j <= 6; $j++)
{
$st_x = ($k + 6) * 40 + ($j + 6) * 40;
$st_y = (6 - $k) * 20 + ($j + 6) * 20;
$coords = ($st_x + 40) . ',' . $st_y . ',' . ($st_x + 80) . ',' . ($st_y + 20) . ',' . ($st_x + 40) . ',' . ($st_y + 40) . ',' . $st_x . ',' . ($st_y + 20);
?>
<?php
}
}
?>
</div>
func.php
<?php
$db_id = mysql_connect($db_host, $db_user, $db_pass)
or die("Could not connect to DB.");
mysql_select_db($db_name, $db_id)
or die("Database not found.");
$result=mysql_query($query, $db_id);
$imgs="default/";
function map($x, $y)
{
global $db_id;
$query="select * from map where (y between ".($y-3)." and ".($y+3).") and (x between ".($x-3)." and ".($x+3).") order by y desc, x asc";
$result=mysql_query($query, $db_id);
$data=array();
for ($i=0; $row=mysql_fetch_row($result); $i++) $data[$i]=$row;
return $data;
}
function map_img($data, $x, $y, &$i, $imgs)
{
echo "src='".$imgs."map/env_";
if (isset($data[$i][0]))
{
if (($data[$i][0]==$x)&&($data[$i][1]==$y))
{
if (!$data[$i][2]) echo "0".rand(1,2);
else echo $data[$i][2].$data[$i][3];
if ($i<count($data)-1) $i++;
}
else echo "x";
echo ".gif'";
}
}
?>
antet.php
<?php include "./language/en.php";
session_start();
$title=$lang['title']; $announcement=$lang['announc']; $m=49; $n=49;
$db_host="localhost";
$db_user="myusertest";
$db_pass="mypasstest";
$db_name="devana";
?>