Class: Player
- Inherits:
-
Object
show all
- Defined in:
- lib/player.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(x, y) ⇒ Player
Returns a new instance of Player.
6
7
8
9
10
11
|
# File 'lib/player.rb', line 6
def initialize(x, y)
@x = x
@y = y
@color = Gosu::Color::BLACK
@data = nil
end
|
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
4
5
6
|
# File 'lib/player.rb', line 4
def color
@color
end
|
#x ⇒ Object
Returns the value of attribute x.
3
4
5
|
# File 'lib/player.rb', line 3
def x
@x
end
|
#y ⇒ Object
Returns the value of attribute y.
3
4
5
|
# File 'lib/player.rb', line 3
def y
@y
end
|
Instance Method Details
#height ⇒ Object
23
24
25
|
# File 'lib/player.rb', line 23
def height
@data.size
end
|
#is_brick(x, y) ⇒ Object
13
14
15
16
17
|
# File 'lib/player.rb', line 13
def is_brick(x, y)
raise 'Error player bounds' if x.negative? || x > width - 1 || y.negative? || y > height - 1
@data[y][x] == 1
end
|
#rotate ⇒ Object
27
28
29
|
# File 'lib/player.rb', line 27
def rotate
@data = @data.reverse.transpose
end
|
#rotate_rollback ⇒ Object
31
32
33
|
# File 'lib/player.rb', line 31
def rotate_rollback
@data = @data.transpose.reverse
end
|
#width ⇒ Object
19
20
21
|
# File 'lib/player.rb', line 19
def width
@data[0].size
end
|