diff --git a/app.rb b/app.rb index 7eeffbd..45e4759 100755 --- a/app.rb +++ b/app.rb @@ -20,8 +20,8 @@ class Window < Gosu::Window @physobjs = physobjs @planets = planets - @font = Gosu::Font.new(self, "monospace", 18) - @font2 = Gosu::Font.new(self, "monospace", 20) + @font = Gosu::Font.new(self, MAIN_FONT, 18) + @font2 = Gosu::Font.new(self, MAIN_FONT, 20) @fonts = { normal: @font, diff --git a/config.rb b/config.rb index 1444654..b91b6d8 100644 --- a/config.rb +++ b/config.rb @@ -2,4 +2,12 @@ MAIN_FONT = "monospace" # Keybinds -BIND_PAUSE = Gosu::KbEscape + # General + BIND_PAUSE = Gosu::KbEscape + + # Player Controlls + BIND_TURN_LEFT = Gosu::KbLeft + BIND_TURN_RIGHT = Gosu::KbRight + BIND_INCREASE_THRUST = Gosu::KbUp + BIND_DECREASE_THRUST = Gosu::KbDown + BIND_TOGGLE_ENGINE = Gosu::KbSpace diff --git a/controller.rb b/controller.rb index 6b7586a..6e30d5b 100644 --- a/controller.rb +++ b/controller.rb @@ -28,24 +28,22 @@ class Player < PhysCube end def button_down(id) - if( id == Gosu::KbSpace ) then + case id + + when BIND_TOGGLE_ENGINE @engine = !@engine - end - if( id == Gosu::KbLeft ) then + when BIND_TURN_LEFT self.angle -= 20 - end - if( id == Gosu::KbRight ) then + when BIND_TURN_RIGHT self.angle += 20 - end - if( id == Gosu::KbUp ) then + when BIND_INCREASE_THRUST self.thrust += 0.0005 self.thrust = self.thrust.round(5) - end - if( id == Gosu::KbDown ) then + when BIND_DECREASE_THRUST self.thrust -= 0.0005 self.thrust = self.thrust.round(5) end