I am creating an online version of Stratego, but I've run into a wall.
I want my pieces to switch places in the initial phase, where you can set up your game.
They are placed within a table.
Table:
Include_once 'StukkenPos.php';
echo '<img src="../../Images/board/strategoboard.png" class="test">';
echo "<table border='1' style='width: 590px; height: 590px' class='test2'>";
for($i = 0; $i < 10; $i++) {
echo "<tr>";
for($j = 0; $j < 10; $j++) {
if (isset($stukken[$i][$j])) {
$stuk = $stukken[$i][$j];
$s = "style= 'z-index:1; width:52px; height:52px; position:inherit'";
$inhoud = "<img src='../../Images/stukken/$stuk' $s>";
} else {
$inhoud = ' ';
}
echo "<td class='cell'; id=${i}_$j; rij=$i col=$j;"
. " style=height:55px>$inhoud</td>";
}
echo "</tr>";
}
echo "<table>";
StukkenPos.php is an array that contains the position of the images and the image that is related to that position innitially. The table is a 10x10 field. The first echo contains the image of the board-background.
The way the pieces/ images are inserted:
<?php
$stukken[0][0] = "b1.png";
$stukken[0][1] = "b2.png";
$stukken[0][2] = "b2.png";
To get me on my feet; Can you get the x,y coordinates of an images with onclick? If so, how do you form your code to get them?
such as:
<img src="b1.png" onclick="//save coordinates;"/>
but then without changing the $stukken array, so it's within another script.