examples/steering_behaviors/steering.rb in lotu-0.1.9 vs examples/steering_behaviors/steering.rb in lotu-0.1.10
- old
+ new
@@ -1,23 +1,25 @@
#!/usr/bin/env ruby
LIB_PATH = File.join(File.dirname(__FILE__), '..', '..', 'lib', 'lotu.rb')
require File.expand_path(LIB_PATH)
+
include Gosu::Button
+include Lotu
-class SteeringRuby < Lotu::Actor
+class SteeringRuby < Actor
def initialize(opts={})
super
set_image 'CptnRuby Gem.png'
- use(Lotu::SteeringSystem, opts)
+ use(SteeringSystem, opts)
end
def warp(x, y)
@pos.x, @pos.y = x, y
end
end
-class Example < Lotu::Window
+class Example < Game
def initialize
# This will call the hooks:
# load_resources, setup_systems and setup_actors
# declared in the parent class
super
@@ -36,30 +38,32 @@
set_keys(KbEscape => :close,
MsRight => :reset_ruby)
end
def setup_systems
- use(Lotu::FpsSystem)
+ # It's important to call super here to setup the InputSystem
+ super
+ use(FpsSystem)
end
def setup_actors
@ruby = SteeringRuby.new(:mass => 0.3, :max_speed => 100, :max_turn_rate => 140)
@ruby.warp(width/2, height/2)
@ruby.activate(:evade)
@ruby2 = SteeringRuby.new
@ruby2.activate(:pursuit)
- @cursor = Lotu::Cursor.new(:image => 'crosshair.png',
- :keys => {MsLeft => [:click, false]})
+ @cursor = Cursor.new(:image => 'crosshair.png',
+ :keys => {MsLeft => [:click, false]})
- @window_info = Lotu::TextBox.new(:size => 15)
- @window_info.watch(@systems[Lotu::FpsSystem])
+ @window_info = TextBox.new(:size => 15)
+ @window_info.watch(@systems[FpsSystem])
@window_info.watch(@cursor, :color => 0xffff0000)
@window_info.text("Click to start the simulation")
@window_info.text("One will pursuit while the other evades, right click to center evader on screen")
- @ruby_info = Lotu::TextBox.new(:attach_to => @ruby, :size => 14)
+ @ruby_info = TextBox.new(:attach_to => @ruby, :size => 14)
@ruby_info.watch(@ruby)
end
def setup_events
@cursor.on(:click) do |x,y|