Sha256: 2e03967b6ade824ce2902e9c0fd533fe9e6e7b59a3a71fdb82a7db892bed62e6
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
#!/usr/bin/env ruby LIB_PATH = File.join(File.dirname(__FILE__), '..', '..', 'lib', 'lotu.rb') require File.expand_path(LIB_PATH) include Gosu::Button class MovingRuby < Lotu::Actor def initialize(opts={}) super # Use the image which filename is CptnRuby Gem.png set_image 'CptnRuby Gem.png' # Map keys to some methods set_keys(KbRight => :move_right, KbLeft => :move_left, KbUp => :move_up, KbDown => :move_down) end # Let's define some basic movement methods def move_right @x += 1 end def move_left @x -= 1 end def move_up @y -= 1 end def move_down @y += 1 end end class Example < Lotu::Window def initialize # This will call the hooks: # load_resources, setup_systems and setup_actors # declared in the parent class super # When the Escape key is pressed, call the close method on class Example set_keys(KbEscape => :close) end def load_resources # From this file, with_path_from_file(__FILE__) do # go back one dir and search inside media/ load_images '../media/' end end def setup_actors @ruby = MovingRuby.new(:x => width/2, :y => height/2) # Create a TextBox so we can display a message on screen @info = Lotu::TextBox.new @info.text("Move around with arrow keys") end end Example.new.show
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lotu-0.1.9 | examples/hello_world/hello_world.rb |