Class: Player

Inherits:
Object
  • Object
show all
Defined in:
lib/player.rb

Direct Known Subclasses

El, ElTwo, Square, Tower, Triangle, Zet, ZetTwo

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

#colorObject (readonly)

Returns the value of attribute color.



4
5
6
# File 'lib/player.rb', line 4

def color
  @color
end

#xObject

Returns the value of attribute x.



3
4
5
# File 'lib/player.rb', line 3

def x
  @x
end

#yObject

Returns the value of attribute y.



3
4
5
# File 'lib/player.rb', line 3

def y
  @y
end

Instance Method Details

#heightObject



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

#rotateObject



27
28
29
# File 'lib/player.rb', line 27

def rotate
  @data = @data.reverse.transpose
end

#rotate_rollbackObject



31
32
33
# File 'lib/player.rb', line 31

def rotate_rollback
  @data = @data.transpose.reverse
end

#widthObject



19
20
21
# File 'lib/player.rb', line 19

def width
  @data[0].size
end