maps2 #2

Merged
lopar merged 23 commits from maps2 into master 2022-02-20 23:15:31 +00:00
Showing only changes of commit d7c85bc110 - Show all commits

View File

@ -0,0 +1,45 @@
<?php
# Date: 20.02.2022 (17:47)
namespace Insallah\Player;
class Player
{
public static function start(array $xy, $force = null)
{
if (!isset($_SESSION['x']) || !isset($_SESSION['y']) || !is_null($force)) {
$_SESSION['x'] = $xy[0];
$_SESSION['y'] = $xy[1];
}
}
public static function getPos(): array
{
return [$_SESSION['x'], $_SESSION['y']];
}
/**
* @param int $x_pos
*/
public static function modXPos(int $x_pos): void
{
if ($_SESSION['x'] + $x_pos >= 0) {
$_SESSION['x'] += $x_pos;
}
}
/**
* @param int $y_pos
*/
public static function modYPos(int $y_pos): void
{
if ($_SESSION['y'] + $y_pos >= 0) {
$_SESSION['y'] += $y_pos;
}
}
public static function clear()
{
session_destroy();
header('Location: ' . $_SERVER['REQUEST_URI']);
}
}