lib/lotu/actor.rb in lotu-0.1.18 vs lib/lotu/actor.rb in lotu-0.1.19
- old
+ new
@@ -1,7 +1,7 @@
module Lotu
- class Actor
+ class Actor < GameEntity
include Lotu::Helpers::Util
extend Lotu::Behavior
behave_like Lotu::SystemUser
behave_like Lotu::Eventful
@@ -13,11 +13,11 @@
:factor_x, :factor_y, :color, :mode, :image,
:width, :height
def initialize(opts={})
# if debug is set, print out class info
- class_debug_info
+ class_debug_info if $lotu.debug
default_opts = {
:x => 0,
:y => 0,
:z => 0,
@@ -41,11 +41,11 @@
# start behaving as
init_behavior opts
# if debug is set, print out instance info
- instance_debug_info
+ instance_debug_info if $lotu.debug
end
# Easy access to delta-time
def dt
$lotu.dt
@@ -58,14 +58,19 @@
@angle = opts[:angle] || @angle
@center_x = opts[:center_x] || @center_x
@center_y = opts[:center_y] || @center_y
@factor_x = opts[:factor_x] || @factor_x
@factor_y = opts[:factor_y] || @factor_y
+ @width = opts[:width]
@color = opts[:color] || @color
if @color.kind_of?(Integer)
@color = Gosu::Color.new(opts[:color])
end
@mode = opts[:mode] || @mode
+ end
+
+ def factor= factor
+ @factor_x = @factor_y = factor
end
def rand_color
Gosu::Color.from_hsv(rand(360), 1, 1)
end