Class: Pitchcar::Pieces::Left
- Inherits:
-
Piece
- Object
- Piece
- Pitchcar::Pieces::Left
show all
- Defined in:
- lib/pieces/left.rb
Constant Summary
collapse
- IMAGE =
Magick::Image.read(File.expand_path('../images/curve_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
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/pieces/left.rb', line 30
def image
if north?
IMAGE.rotate(180)
elsif east?
IMAGE.rotate(270)
elsif west?
IMAGE.rotate(90)
elsif south?
IMAGE
end
end
|
#next_coordinate ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/pieces/left.rb', line 18
def next_coordinate
if north?
{ x: x - 1, y: y }
elsif east?
{ x: x, y: y + 1 }
elsif west?
{ x: x, y: y - 1 }
elsif south?
{ x: x + 1, y: y }
end
end
|
#next_direction ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/pieces/left.rb', line 6
def next_direction
if north?
DIRECTIONS[:WEST]
elsif east?
DIRECTIONS[:NORTH]
elsif west?
DIRECTIONS[:SOUTH]
elsif south?
DIRECTIONS[:EAST]
end
end
|
#to_s ⇒ Object
42
43
44
|
# File 'lib/pieces/left.rb', line 42
def to_s
'L'
end
|