Class: Rubygoo::GosuAppAdapter
- Inherits:
-
Object
- Object
- Rubygoo::GosuAppAdapter
- Defined in:
- lib/rubygoo/adapters/gosu_app_adapter.rb
Instance Method Summary collapse
-
#button_down(id) ⇒ Object
TODO convert keys?!?.
- #button_up(id) ⇒ Object
- #draw(target) ⇒ Object
-
#initialize(app, main_window) ⇒ GosuAppAdapter
constructor
A new instance of GosuAppAdapter.
- #update(time) ⇒ Object
Constructor Details
#initialize(app, main_window) ⇒ GosuAppAdapter
Returns a new instance of GosuAppAdapter.
486 487 488 489 490 491 492 |
# File 'lib/rubygoo/adapters/gosu_app_adapter.rb', line 486 def initialize(app,main_window) @app = app @main_window = main_window @last_mouse_x = 0 @last_mouse_y = 0 end |
Instance Method Details
#button_down(id) ⇒ Object
TODO convert keys?!?
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
# File 'lib/rubygoo/adapters/gosu_app_adapter.rb', line 509 def (id) case id when MsLeft @app.on_event GooEvent.new(:mouse_down, { :x => @main_window.mouse_x, :y => @main_window.mouse_y, :button => MOUSE_LEFT}) else # assume it's a key # where do I get the mods? ie shift,alt,ctrl # where do I get the string rep of the char? mods = [] mods << K_LALT if @main_window. KbLeftAlt mods << K_RALT if @main_window. KbRightAlt mods << K_LCTRL if @main_window. KbLeftControl mods << K_RCTRL if @main_window. KbRightControl left_shift = @main_window. KbLeftShift right_shift = @main_window. KbRightShift mods << K_LSHIFT if left_shift mods << K_RSHIFT if right_shift = @main_window.(id) ||= "?" .upcase! if left_shift or right_shift @app.on_event GooEvent.new(:key_pressed, { :key => id, :mods => mods, :string => }) end end |
#button_up(id) ⇒ Object
539 540 541 542 543 544 545 546 |
# File 'lib/rubygoo/adapters/gosu_app_adapter.rb', line 539 def (id) case id when MsLeft @app.on_event GooEvent.new(:mouse_up, { :x => @main_window.mouse_x, :y => @main_window.mouse_y, :button => MOUSE_LEFT}) end end |
#draw(target) ⇒ Object
504 505 506 |
# File 'lib/rubygoo/adapters/gosu_app_adapter.rb', line 504 def draw(target) @app.draw target end |
#update(time) ⇒ Object
494 495 496 497 498 499 500 501 502 |
# File 'lib/rubygoo/adapters/gosu_app_adapter.rb', line 494 def update(time) x = @main_window.mouse_x y = @main_window.mouse_y if x != @last_mouse_x or y != @last_mouse_y @app.on_event GooEvent.new(:mouse_motion, { :x => x, :y => y}) end @app.update time end |