Class: SpaceDozer::Tile

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y) ⇒ Tile

Returns a new instance of Tile.


7
8
9
10
11
# File 'lib/spacedozer/tile.rb', line 7

def initialize(x, y)
  @coordinates = [x, y]
  @x = x
  @y = y / 2
end

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x


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

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y


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

def y
  @y
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)

32
33
34
# File 'lib/spacedozer/tile.rb', line 32

def changed?
  @changed
end

#killObject


17
18
19
20
21
# File 'lib/spacedozer/tile.rb', line 17

def kill
  score[type] += 1

  empty
end

#scoreObject


13
14
15
# File 'lib/spacedozer/tile.rb', line 13

def score
  @score ||= Hash.new(0)
end

#typeObject


23
24
25
# File 'lib/spacedozer/tile.rb', line 23

def type
  @type ||= :empty
end

#updateObject


36
37
38
39
40
# File 'lib/spacedozer/tile.rb', line 36

def update
  @changed = false

  Console.draw Console::Color[type], *@coordinates
end