Example #1
0
              <div>
      	<p>Mouvements</p>
      	    <form action="Moves.php" name="move" method="POST">
      	     <select style='width:150px;' name="ship">
      	    <?php 
display_name();
?>
      	    </select>
      		<input type="number" min="0" max="50" name="movenb" id="movenb" placeholder="move">
      		<button type="submit"></button>
      		</form>
			<button type="submit" id="turn_r">left</button>
			<button type="submit" id="turn_l">left</button>
		</div>
      </p>
     </div>
  <div id="mypan" class="panel">
  <div id="shipname" class="shipnamec"></div>
  <div id="shipstats" class="shipstatsc"></div>
  <div id="shipweapons" class="shipweaponsc"></div>
  <button type="submit" id="ChangePhase">Change Phase</button>
  </div>
    <script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
    <script src="panel.js"></script>
</body>
</html>
<?php 
$game = $_SESSION['game'];
foreach ($game->getShip() as $key => $value) {
    posship($value, $key);
}
Example #2
0
    $pos = $ship->getPos();
    $size = $ship->getSize();
    $x = $pos['x'] * 10 + 2 * $pos['x'];
    $y = $pos['y'] * 10 + 2 * $pos['y'];
    $width = $size['height'] * 10 + 2 * $size['height'];
    if ($ship->getDirection() == Ship::SOUTH) {
        $rotate = 'transform-origin: 50% 50%;transform : rotate(90deg);';
    } else {
        if ($ship->getDirection() == Ship::NORTH) {
            $rotate = 'transform-origin: 50% 50%;transform : rotate(270deg);';
        } else {
            if ($ship->getDirection() == Ship::WEST) {
                $rotate = 'transform-origin: 50% 50%;transform : rotateY(180deg);';
            } else {
                $rotate = "";
            }
        }
    }
    return json_encode(array('x' => $x, 'y' => $y));
    // echo '<div style=" ' . $rotate . 'position: absolute; left:' . $x . '; top:' . $y . ';">
    // 	<img src="' . $ship->getSprite() . '" width ="' . $width . 'px" data-ship="'.$key.'"  class="ship"></div>';
}
$ship = $_SESSION['game']->getShip();
if ($nb = $_POST['movenb']) {
    $ship = $ship[$_POST['ship']];
    if ($nb > 0 && $nb <= $ship->getCm()) {
        $ship->move_on($nb);
    }
    echo posship($ship, $_POST['ship']);
}
header("Location: main_page.php");