lib/lotu/actor.rb in lotu-0.1.1 vs lib/lotu/actor.rb in lotu-0.1.2

- old
+ new

@@ -1,20 +1,27 @@ module Lotu class Actor - extend HasBehavior - attr_accessor :parent, :x, :y def initialize(opts={}) - super() - @x = opts[:x] || 0 - @y = opts[:y] || 0 + default_opts = { + :x => 0, + :y => 0, + :color => 0xffffffff + } + opts = default_opts.merge!(opts) + @x = opts[:x] + @y = opts[:y] + @color = opts[:color] @parent = $window @parent.update_queue << self - # Initialize the behaviors included in subclasses - init_behavior + # Add extra functionality + self.extend Drawable + self.extend Controllable + self.extend Eventful + self.extend Collidable end # Easy access to delta-time def dt $window.dt @@ -23,10 +30,8 @@ # Remove ourselves from the update queue def die @parent.update_queue.delete(self) end - # Meant to be overriden by behaviors - def init_behavior;end def update;end end end