Ejemplo n.º 1
0
 public function translate_offset($forward, $right)
 {
     $direction = Position::normalize_direction($this->direction());
     switch ($direction) {
         case 'north':
             return [$this->x + (int) $right, $this->y - (int) $forward];
             break;
         case 'east':
             return [$this->x + (int) $forward, $this->y + (int) $right];
             break;
         case 'south':
             return [$this->x - (int) $right, $this->y + (int) $forward];
             break;
         case 'west':
             return [$this->x - (int) $forward, $this->y - (int) $right];
             break;
     }
 }