Class: Tree

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

Instance Attribute Summary collapse

Attributes inherited from GameObject

#components, #location, #x, #y

Instance Method Summary collapse

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

#graphicsObject (readonly)

Returns the value of attribute graphics.



2
3
4
# File 'lib/entities/tree.rb', line 2

def graphics
  @graphics
end

#healthObject (readonly)

Returns the value of attribute health.



2
3
4
# File 'lib/entities/tree.rb', line 2

def health
  @health
end

Instance Method Details

#boxObject



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