Sha256: 311518af9534628d48291150e3b6c6d6453e73c31d9c29c502aa6decd17bbab4

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 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 WarpingRuby < Lotu::Actor
  def initialize
    super
    set_image 'CptnRuby Gem.png'
  end

  def warp(x, y)
    @x, @y = x, y
  end
end

class Example < Lotu::Window
  def initialize
    super
    set_keys KbEscape => :close

    with_path __FILE__ do
      load_images '../media'
    end

    @ruby = WarpingRuby.new
    @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.on(:click) do |x,y|
      @ruby.warp(x,y)
    end
    @cursor2.on(:click) do |x,y|
      @ruby.warp(x,y)
    end

    @cursor2.x = width*3/4
    @cursor2.y = height/2

    @info = Lotu::TextBox.new
    @info.watch(@fps_counter)
    @info.watch("@cursor1 data:")
    @info.watch(@cursor1, :color => 0xff0099ff, :font_size => 15)
    @info.watch("@cursor2 data:")
    @info.watch(@cursor2, :color => 0xff99ff00, :font_size => 15)
  end

end

Example.new.show

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lotu-0.1.4 examples/mouse_pointer/mouse_pointer.rb