Browse Source

session start

ruben
Ruben De Baets 4 years ago
parent
commit
e44e2ce42d
2 changed files with 36 additions and 42 deletions
  1. 1
    0
      .gitignore
  2. 35
    42
      index.php

+ 1
- 0
.gitignore View File

@@ -0,0 +1 @@
.history/

+ 35
- 42
index.php View File

@@ -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 "&nbsp;"; //visualize the hit array here, work in progress
}
echo '|';
}
//Create the center rows
else {
echo '|';
for ($x == 1; $x <= $fieldSizeX; ++$x) {
echo "&nbsp;"; //visualize the hit array here, work in progress
}
echo "<br/>";
echo '|';
}
echo "<br/>";
}
?>

</body>

Loading…
Cancel
Save