Class: Pitchcar::Pieces::Straight
- Inherits:
-
Piece
- Object
- Piece
- Pitchcar::Pieces::Straight
show all
- Defined in:
- lib/pieces/straight.rb
Constant Summary
collapse
- IMAGE =
Magick::Image.read(File.expand_path('../images/straight_tile.png', __FILE__))[0]
Constants inherited
from Piece
Piece::DIRECTIONS
Instance Attribute Summary
Attributes inherited from Piece
#direction, #type, #x, #y
Instance Method Summary
collapse
Methods inherited from Piece
#coordinate, first_from_string, #initialize, #name, #to_h, type_from_string
Instance Method Details
#image ⇒ Object
21
22
23
24
|
# File 'lib/pieces/straight.rb', line 21
def image
return IMAGE.rotate(90) if north? || south?
IMAGE
end
|
#next_coordinate ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/pieces/straight.rb', line 9
def next_coordinate
if north?
{ x: x, y: y + 1 }
elsif east?
{ x: x + 1, y: y }
elsif west?
{ x: x - 1, y: y }
elsif south?
{ x: x, y: y - 1 }
end
end
|
#next_direction ⇒ Object
5
6
7
|
# File 'lib/pieces/straight.rb', line 5
def next_direction
direction
end
|
#to_s ⇒ Object
26
27
28
|
# File 'lib/pieces/straight.rb', line 26
def to_s
'S'
end
|