Class: Tree
- Inherits:
-
GameObject
- Object
- GameObject
- Tree
- Defined in:
- lib/entities/tree.rb
Instance Attribute Summary collapse
-
#graphics ⇒ Object
readonly
Returns the value of attribute graphics.
-
#health ⇒ Object
readonly
Returns the value of attribute health.
Attributes inherited from GameObject
#components, #location, #x, #y
Instance Method Summary collapse
- #box ⇒ Object
-
#initialize(object_pool, x, y, seed) ⇒ Tree
constructor
A new instance of Tree.
- #on_collision(object) ⇒ Object
Methods inherited from GameObject
#collide, #draw, #effect?, #mark_for_removal, #move, #removable?, #update
Constructor Details
#initialize(object_pool, x, y, seed) ⇒ Tree
Returns a new instance of Tree.
4 5 6 7 8 9 |
# File 'lib/entities/tree.rb', line 4 def initialize(object_pool, x, y, seed) super(object_pool, x, y) @graphics = TreeGraphics.new(self, seed) @health = Health.new(self, object_pool, 30, false) @angle = rand(-15..15) end |
Instance Attribute Details
#graphics ⇒ Object (readonly)
Returns the value of attribute graphics.
2 3 4 |
# File 'lib/entities/tree.rb', line 2 def graphics @graphics end |
#health ⇒ Object (readonly)
Returns the value of attribute health.
2 3 4 |
# File 'lib/entities/tree.rb', line 2 def health @health end |
Instance Method Details
#box ⇒ Object
15 16 17 |
# File 'lib/entities/tree.rb', line 15 def box [@x, @y] end |
#on_collision(object) ⇒ Object
11 12 13 |
# File 'lib/entities/tree.rb', line 11 def on_collision(object) @graphics.shake(object.direction) end |