physics
E. Almqvist 3 years ago
parent d8a646621b
commit c35923e368
  1. 33
      src/app.rb
  2. 14
      src/config.rb

@ -82,9 +82,9 @@ class Window < Gosu::Window
@key_events[:down].delete(id) # when the key is released: stop holding it @key_events[:down].delete(id) # when the key is released: stop holding it
@key_events[:up] << id # append the key event to the queue @key_events[:up] << id # append the key event to the queue
if( @world && @world.controller ) then # if( @world && @world.controller ) then
@world.controller.button_up(id) # @world.controller.button_up(id)
end # end
end end
def button_down(id) def button_down(id)
@ -92,29 +92,32 @@ class Window < Gosu::Window
print "down: " print "down: "
p id p id
if( id == BIND_PAUSE ) then # if( id == BIND_PAUSE ) then
@freeze = !@freeze # @freeze = !@freeze
end # end
#
if( @world && @world.controller ) then # if( @world && @world.controller ) then
@world.controller.button_down(id) # @world.controller.button_down(id)
end # end
end end
def button_up?(id) def button_up?(id)
super id super id
if( @world && @world.controller ) then # if( @world && @world.controller ) then
@world.controller.button_up?(id) # @world.controller.button_up?(id)
end # end
end end
def button_down?(id) def button_down?(id)
super id super id
if( @world && @world.controller ) then # if( @world && @world.controller ) then
@world.controller.button_down?(id) # @world.controller.button_down?(id)
# end
end end
private def broadcast_event(event)
end end
def update def update

@ -17,3 +17,17 @@ MAIN_FONT = "monospace"
BIND_INCREASE_THRUST = Gosu::KbUp BIND_INCREASE_THRUST = Gosu::KbUp
BIND_DECREASE_THRUST = Gosu::KbDown BIND_DECREASE_THRUST = Gosu::KbDown
BIND_TOGGLE_ENGINE = Gosu::KbSpace BIND_TOGGLE_ENGINE = Gosu::KbSpace
# Key events
KEY_EVENTS = {
# UI
BIND_PAUSE => :pause,
# Player Controlls
BIND_TURN_LEFT => :turn_left,
BIND_TURN_RIGHT => :turn_right,
BIND_INCREASE_THRUST => :increase_thrust,
BIND_DECREASE_THRUST => :decrease_thrust,
BIND_TOGGLE_ENGINE => :toggle_engine
}

Loading…
Cancel
Save