Class: Pacman::Arcade::Position
- Inherits:
-
Data
- Object
- Data
- Pacman::Arcade::Position
- Defined in:
- lib/pacman/arcade/position.rb
Instance Attribute Summary collapse
-
#col ⇒ Object
readonly
Returns the value of attribute col.
-
#row ⇒ Object
readonly
Returns the value of attribute row.
Instance Method Summary collapse
Instance Attribute Details
#col ⇒ Object (readonly)
Returns the value of attribute col
5 6 7 |
# File 'lib/pacman/arcade/position.rb', line 5 def col @col end |
#row ⇒ Object (readonly)
Returns the value of attribute row
5 6 7 |
# File 'lib/pacman/arcade/position.rb', line 5 def row @row end |
Instance Method Details
#distance_sq(other) ⇒ Object
10 11 12 |
# File 'lib/pacman/arcade/position.rb', line 10 def distance_sq(other) ((row - other.row)**2) + ((col - other.col)**2) end |
#step(direction) ⇒ Object
6 7 8 |
# File 'lib/pacman/arcade/position.rb', line 6 def step(direction) Position.new(row: row + direction.dy, col: col + direction.dx) end |