lib/units/thing.rb in gosu_extensions-0.1.15 vs lib/units/thing.rb in gosu_extensions-0.1.16

- old
+ new

@@ -20,10 +20,15 @@ after_initialize end # Default layer is Layer::Players. # + def self.layer layer + InitializerHooks.register self do + self.layer = layer + end + end def layer @layer || Layer::Players end class << self @@ -62,16 +67,10 @@ InitializerHooks.append self.class, &to_execute unless @shape to_execute[@shape] end end - def layer layer - InitializerHooks.register self do - self.layer = layer - end - end - # Plays a random sound of the given sounds. # def plays paths, options = {} paths = [*paths] InitializerHooks.register self do @@ -120,22 +119,24 @@ self.instance_variable_set name, false end result end - # Add this thing to a space. + # Add this thing to an environment. # # Note: Adds the body and the shape. # - def add_to space - space.add_body @shape.body - space.add_shape @shape + def add_to environment + environment.add_body self.shape.body # could develop into adding multiple bodies + environment.add_shape self.shape end - # TODO include size + # Draws its image. # def draw - # size = self.momentary_size TODO - self.image.draw_rot self.position.x, self.position.y, self.layer, self.drawing_rotation, 0.5, 0.5, 1.0, 1.0 + self.image.draw_rot self.position.x, self.position.y, self.layer, self.drawing_rotation, 0.5, 0.5, *self.current_size + end + def current_size + [1.0, 1.0] # default implementation - change this to [1.0, 2.0] if you want a "light" version ;) end end \ No newline at end of file