Sha256: 28b1b108131aa7afc0582149b8a8019441cf447ae76339fa1187a6518f2e63c9

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

require 'rubygame'
include Rubygame
include Mouse
include Key

module Rubygoo

  class RubygameAppAdapter

    def initialize(app)
      @app = app
    end

    def update(time)
      @app.update time
    end

    def draw(target)
      @app.draw target
    end

    # TODO convert keys?!?
    def on_event(event)
      case event
      when KeyUpEvent
        @app.on_event GooEvent.new(:key_released, { 
          :key => event.key, :mods => event.mods, :string => event.string})
      when KeyDownEvent
        @app.on_event GooEvent.new(:key_pressed, { 
          :key => event.key, :mods => event.mods, :string => event.string})
      when MouseUpEvent
        @app.on_event GooEvent.new(:mouse_up, { 
          :x => event.pos[0], :y => event.pos[1], :button => event.button})
      when MouseDownEvent
        @app.on_event GooEvent.new(:mouse_down, { 
          :x => event.pos[0], :y => event.pos[1], :button => event.button})
      when MouseMotionEvent
        @app.on_event GooEvent.new(:mouse_motion, { 
          :x => event.pos[0], :y => event.pos[1]})
      end
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubygoo-0.0.4 lib/rubygoo/adapters/rubygame_app_adapter.rb
rubygoo-0.0.6 lib/rubygoo/adapters/rubygame_app_adapter.rb
rubygoo-0.0.5 lib/rubygoo/adapters/rubygame_app_adapter.rb
rubygoo-0.0.8 lib/rubygoo/adapters/rubygame_app_adapter.rb
rubygoo-0.0.7 lib/rubygoo/adapters/rubygame_app_adapter.rb