.
This commit is contained in:
parent
7b9346cb6b
commit
9d2bb1fc03
|
@ -5,5 +5,38 @@ class Direction
|
|||
private static $bottom = 1;
|
||||
private static $left = 2;
|
||||
private static $right = 3;
|
||||
|
||||
|
||||
private $value;
|
||||
|
||||
public function __construct(){
|
||||
$this->value = 0;
|
||||
}
|
||||
public function __toString(){
|
||||
switch ($this->value){
|
||||
case Direction::$top:
|
||||
return "y+";
|
||||
break;
|
||||
case Direction::$bottom:
|
||||
return "y-";
|
||||
break;
|
||||
case Direction::$left:
|
||||
return "x-";
|
||||
break;
|
||||
case Direction::$right:
|
||||
return "x+";
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function opposite(){
|
||||
$opposites = array(
|
||||
Direction::$top => Direction::$bottom,
|
||||
Direction::$bottom => Direction::$top,
|
||||
Direction::$left => Direction::$right,
|
||||
Direction::$right => Direction::$left
|
||||
);
|
||||
|
||||
$opposite = new Direction();
|
||||
$opposite->value = $opposites[$this->value];
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user