class GameObject

Attributes

components[R]
location[R]
x[R]
y[R]

Public Class Methods

new(object_pool, x, y) click to toggle source
# File lib/entities/game_object.rb, line 3
def initialize(object_pool, x, y)
  @x, @y = x, y
  @location = [x, y]
  @components = []
  @object_pool = object_pool
  @object_pool.add(self)
end

Public Instance Methods

box() click to toggle source
# File lib/entities/game_object.rb, line 43
def box
end
collide() click to toggle source
# File lib/entities/game_object.rb, line 46
def collide
end
draw(viewport) click to toggle source
# File lib/entities/game_object.rb, line 24
def draw(viewport)
  @components.each { |c| c.draw(viewport) }
end
effect?() click to toggle source
# File lib/entities/game_object.rb, line 39
def effect?
  false
end
mark_for_removal() click to toggle source
# File lib/entities/game_object.rb, line 32
def mark_for_removal
  @removable = true
end
move(new_x, new_y) click to toggle source
# File lib/entities/game_object.rb, line 11
def move(new_x, new_y)
  return if new_x == @x && new_y == @y
  @object_pool.tree_remove(self)
  @x = new_x
  @y = new_y
  @location = [new_x, new_y]
  @object_pool.tree_insert(self)
end
on_collision(object) click to toggle source
# File lib/entities/game_object.rb, line 36
def on_collision(object)
end
removable?() click to toggle source
# File lib/entities/game_object.rb, line 28
def removable?
  @removable
end
update() click to toggle source
# File lib/entities/game_object.rb, line 20
def update
  @components.map(&:update)
end

Protected Instance Methods

object_pool() click to toggle source
# File lib/entities/game_object.rb, line 51
def object_pool
  @object_pool
end