Hallo,
Ich möchte gerne eine kleine Map mittels PHP erzeugen in einem Grid z.B 15x15. Das ganze soll in etw so aussehen:
http://www.soundwerkstatt.ch/program...-generator.php
Die Map wird bereits generiert aber ich habe mühe die Coordinaten mittels URL zu parsen (map.php?x=17&y=12) Ich will später beim draufklicken diese Koordinaten als Variable übergeben.
Kann mir jemand auf die Sprünge helfen bitte? Lieben Dank
Randy
Hier ist der Code soweit:
Code:
<?php
$map = array();
$terrain = array ('plains', 'water', 'forest');
for ($row = 0; $row < 15; $row++) {
$map[] = array();
for ($column = 0; $column < 15; $column++) {
$pool = $terrain;
if (isset($map[$row-1])) {
if (isset($map[$row-1][$column-1])) {
$pool[] = $map[$row-1][$column-1];
$pool[] = $map[$row-1][$column-1];
}
$pool[] = $map[$row-1][$column];
$pool[] = $map[$row-1][$column];
if (isset($map[$row-1][$column+1])) {
$pool[] = $map[$row-1][$column+1];
$pool[] = $map[$row-1][$column+1];
}
}
if (isset($map[$row][$column-1])) {
$pool[] = $map[$row][$column-1];
$pool[] = $map[$row][$column-1];
}
shuffle($pool);
$map[$row][$column] = $pool[0];
$x = $row;
$y = $$column;
}
}
?>
<table cellspacing='0' cellpadding='0' border='0'>
<?php foreach ($map as $row) { ?>
<tr>
<?php foreach ($row as $tile) { ?>
<td><a href="map.php?x=<?php echo $x; ?>&y=<?php echo $y; ?>"><img src='tile_<?php echo $tile ?>.png'></a></td>
<?php } ?>
</tr>
<?php }
?>
</table>