|
|
@@ -1,4 +1,7 @@ |
|
|
|
<html> |
|
|
|
<?php |
|
|
|
session_start(); |
|
|
|
?> |
|
|
|
|
|
|
|
<body> |
|
|
|
|
|
|
@@ -6,56 +9,46 @@ |
|
|
|
|
|
|
|
<form method="POST"> |
|
|
|
Shot: <input name="shot" /><br /> |
|
|
|
|
|
|
|
|
|
|
|
<input type="submit" /> |
|
|
|
</form> |
|
|
|
|
|
|
|
<?php |
|
|
|
|
|
|
|
$fieldSizeX = 10; |
|
|
|
$fieldSizeY = 1; |
|
|
|
$subPosition = rand(0, $fieldSizeX -1); |
|
|
|
$subLength = 1; |
|
|
|
$positionsFired = array(); |
|
|
|
$won = false; |
|
|
|
|
|
|
|
$shot = $_POST['shot']; |
|
|
|
|
|
|
|
if($subPosition == $shot) |
|
|
|
{ |
|
|
|
$won = true; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
array_push($positionsFired, $shot); |
|
|
|
} |
|
|
|
|
|
|
|
for($y == 0; $y <= $fieldSizeY + 1; ++$y) |
|
|
|
{ |
|
|
|
//Create the upper and lower border |
|
|
|
if($y == 0 || $y == $fieldSizeY + 1) |
|
|
|
{ |
|
|
|
for($i = 0; $i <= $fieldSizeX +1; ++$i) |
|
|
|
{ |
|
|
|
if($i == 0 || $i == $fieldSizeX +1) |
|
|
|
{ |
|
|
|
echo '+'; |
|
|
|
} |
|
|
|
else echo '-'; |
|
|
|
} |
|
|
|
$fieldSizeX = 10; |
|
|
|
$fieldSizeY = 1; |
|
|
|
$subPosition = rand(0, $fieldSizeX - 1); |
|
|
|
$subLength = 1; |
|
|
|
$positionsFired = array(); |
|
|
|
$won = false; |
|
|
|
|
|
|
|
$shot = $_POST['shot']; |
|
|
|
|
|
|
|
if ($subPosition == $shot) { |
|
|
|
$won = true; |
|
|
|
} else { |
|
|
|
array_push($positionsFired, $shot); |
|
|
|
} |
|
|
|
|
|
|
|
for ($y == 0; $y <= $fieldSizeY + 1; ++$y) { |
|
|
|
//Create the upper and lower border |
|
|
|
if ($y == 0 || $y == $fieldSizeY + 1) { |
|
|
|
for ($i = 0; $i <= $fieldSizeX + 1; ++$i) { |
|
|
|
if ($i == 0 || $i == $fieldSizeX + 1) { |
|
|
|
echo '+'; |
|
|
|
} else echo '-'; |
|
|
|
} |
|
|
|
//Create the center rows |
|
|
|
else |
|
|
|
{ |
|
|
|
echo '|'; |
|
|
|
for($x == 1; $x <= $fieldSizeX; ++$x) |
|
|
|
{ |
|
|
|
echo " "; //visualize the hit array here, work in progress |
|
|
|
} |
|
|
|
echo '|'; |
|
|
|
} |
|
|
|
//Create the center rows |
|
|
|
else { |
|
|
|
echo '|'; |
|
|
|
for ($x == 1; $x <= $fieldSizeX; ++$x) { |
|
|
|
echo " "; //visualize the hit array here, work in progress |
|
|
|
} |
|
|
|
echo "<br/>"; |
|
|
|
echo '|'; |
|
|
|
} |
|
|
|
echo "<br/>"; |
|
|
|
} |
|
|
|
?> |
|
|
|
|
|
|
|
</body> |