class playersTron
This commit is contained in:
parent
7599202cbb
commit
0252c5b899
|
@ -5,7 +5,7 @@ class TronPlayer{
|
||||||
private $name;
|
private $name;
|
||||||
private $tail = array();
|
private $tail = array();
|
||||||
private $direction;
|
private $direction;
|
||||||
public $state;
|
private $state;
|
||||||
|
|
||||||
private function set_direction($newDir){
|
private function set_direction($newDir){
|
||||||
//can't be the opposite of the previous direction
|
//can't be the opposite of the previous direction
|
||||||
|
@ -25,7 +25,9 @@ class TronPlayer{
|
||||||
if($dir == ""){
|
if($dir == ""){
|
||||||
$dir = $this->direction;
|
$dir = $this->direction;
|
||||||
}
|
}
|
||||||
|
if(!$this->set_direction()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$headCoords = end($this->tail);
|
$headCoords = end($this->tail);
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,6 +48,7 @@ class TronPlayer{
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$this->tail[] = $targetCoords;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user