examples/mouse_pointer/mouse_pointer.rb in lotu-0.1.9 vs examples/mouse_pointer/mouse_pointer.rb in lotu-0.1.10

- old
+ new

@@ -1,22 +1,24 @@ #!/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 WarpingRuby < Lotu::Actor +class WarpingRuby < Actor def initialize(opts={}) super set_image 'CptnRuby Gem.png' end def warp(x, y) @x, @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 @@ -30,34 +32,36 @@ load_images '../media' end end def setup_systems - use(Lotu::FpsSystem) - use(Lotu::StalkerSystem, :stalk => [Lotu::Actor, Lotu::InputController, Object]) + # It's important to call super here to setup the InputSystem + super + use(FpsSystem) + use(StalkerSystem, :stalk => [Actor, Cursor, WarpingRuby, TextBox, Object]) end def setup_actors @ruby = WarpingRuby.new(:x => width/2, :y => height/2) - @cursor1 = Lotu::Cursor.new(:image => 'crosshair.png', - :keys => {MsLeft => [:click, false]}, - :color => 0xff0099ff) - @cursor2 = Lotu::Cursor.new(:image => 'crosshair.png', - :use_mouse => false, - :keys => { - KbSpace => [:click, false], - KbUp => :up, - KbDown => :down, - KbLeft => :left, - KbRight => :right}, - :color => 0xff99ff00) + @cursor1 = Cursor.new(:image => 'crosshair.png', + :keys => {MsLeft => [:click, false]}, + :color => 0xff0099ff) + @cursor2 = Cursor.new(:image => 'crosshair.png', + :use_mouse => false, + :keys => { + KbSpace => [:click, false], + KbUp => :up, + KbDown => :down, + KbLeft => :left, + KbRight => :right}, + :color => 0xff99ff00) @cursor2.x = width*3/4 @cursor2.y = height/2 # Create a TextBox with default option :size => 15 - @info = Lotu::TextBox.new(:size => 15) - @info.watch(@systems[Lotu::FpsSystem]) - @info.watch(@systems[Lotu::StalkerSystem]) + @info = TextBox.new(:size => 15) + @info.watch(@systems[FpsSystem]) + @info.watch(@systems[StalkerSystem]) # We can change the size for a specific line of text @info.watch("@cursor1 data:", :size => 20) # Color too @info.watch(@cursor1, :color => 0xff0099ff) @info.watch("@cursor2 data:", :size => 20)