Sha256: 42db5ec4c2eea376ebe595b6fdd7b1474c601f9290e4d3fdb7d2e7989b4bcc90

Contents?: true

Size: 785 Bytes

Versions: 2

Compression:

Stored size: 785 Bytes

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
    set_image 'CptnRuby Gem.png'
    set_keys(KbRight => :move_right,
             KbLeft => :move_left,
             KbUp => :move_up,
             KbDown => :move_down)
  end

  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
    super
    set_keys(KbEscape => :close)

    with_path(__FILE__) do
      load_images '../media'
    end

    @ruby = MovingRuby.new(:x => width/2, :y => height/2)
  end

end

Example.new.show

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lotu-0.1.5 examples/hello_world/hello_world.rb
lotu-0.1.4 examples/hello_world/hello_world.rb