class playersTron

This commit is contained in:
Gnieark 2016-06-29 16:42:21 +02:00
parent 7599202cbb
commit 0252c5b899

View File

@ -5,7 +5,7 @@ class TronPlayer{
private $name;
private $tail = array();
private $direction;
public $state;
private $state;
private function set_direction($newDir){
//can't be the opposite of the previous direction
@ -25,7 +25,9 @@ class TronPlayer{
if($dir == ""){
$dir = $this->direction;
}
if(!$this->set_direction()){
return false;
}
$headCoords = end($this->tail);
@ -46,6 +48,7 @@ class TronPlayer{
return false;
}
$this->tail[] = $targetCoords;
}