Class: Upgrade

Inherits:
GameObject show all
Defined in:
lib/entities/upgrade.rb

Overview

class Upgrade

Instance Attribute Summary collapse

Attributes inherited from GameObject

#collider, #x, #y

Instance Method Summary collapse

Methods inherited from GameObject

#collide?, #collision_detect, #draw, #hitted, #solid?

Constructor Details

#initialize(x, y, type) ⇒ Upgrade



7
8
9
10
11
12
13
# File 'lib/entities/upgrade.rb', line 7

def initialize(x, y, type)
  super(x, y, 2, 2, true)
  @type = type
  @sprite = @sprite = Sprite.new(@type, true, 500)
  @taken = false
  @lifetime = 900 # cca 15 sekund
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/entities/upgrade.rb', line 5

def type
  @type
end

Instance Method Details

#done?Boolean



24
25
26
# File 'lib/entities/upgrade.rb', line 24

def done?
  @taken || @lifetime == 0
end

#taken(_obj) ⇒ Object



15
16
17
# File 'lib/entities/upgrade.rb', line 15

def taken(_obj)
  @taken = true
end

#updateObject



19
20
21
22
# File 'lib/entities/upgrade.rb', line 19

def update
  @lifetime -= 1 if @lifetime > 0
  @sprite.update
end