Class: GameWindow
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- GameWindow
- Defined in:
- lib/lib/user_interface/game_window.rb
Overview
Main window
Instance Attribute Summary collapse
-
#win ⇒ Object
readonly
Returns the value of attribute win.
Instance Method Summary collapse
-
#button_up(key) ⇒ Object
Start processing the pushed button.
-
#check_win ⇒ Object
Check whether player has won yet.
-
#draw ⇒ Object
Draw scene.
-
#initialize(version, width = WINDOW_WIDTH, height = WINDOW_HEIGHT, fullscreen = false) ⇒ GameWindow
constructor
A new instance of GameWindow.
-
#reset ⇒ Object
Reset scene.
-
#reset! ⇒ Object
Load default setup.
-
#switch_debug! ⇒ Object
Switch debug flag.
-
#update ⇒ Object
Process given button.
Constructor Details
#initialize(version, width = WINDOW_WIDTH, height = WINDOW_HEIGHT, fullscreen = false) ⇒ GameWindow
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lib/user_interface/game_window.rb', line 26 def initialize(version, width = WINDOW_WIDTH, \ height = WINDOW_HEIGHT, \ fullscreen = false) super(width, height, fullscreen) # Set version name self.caption = "Crane Construction #{version}" $debug = false # debug messages turned off by default reset! @background = Background.new() @infopane = Infopane.new(self) @brickyard = Brickyard.new() @crane = Crane.new() @hook = Hook.new(self, @brickyard, @crane) @brickyard.produce! end |
Instance Attribute Details
#win ⇒ Object (readonly)
Returns the value of attribute win.
24 25 26 |
# File 'lib/lib/user_interface/game_window.rb', line 24 def win @win end |
Instance Method Details
#button_up(key) ⇒ Object
Start processing the pushed button
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/lib/user_interface/game_window.rb', line 48 def (key) case key when Gosu::KB_ESCAPE then self.close when Gosu::KB_BACKSPACE then reset when Gosu::KB_TAB then switch_debug! else = key end end |
#check_win ⇒ Object
Check whether player has won yet
76 77 78 |
# File 'lib/lib/user_interface/game_window.rb', line 76 def check_win false # TODO end |
#draw ⇒ Object
Draw scene
81 82 83 84 85 86 87 88 |
# File 'lib/lib/user_interface/game_window.rb', line 81 def draw @background.draw @infopane.draw @brickyard.draw @crane.draw @hook.draw end |
#reset ⇒ Object
Reset scene
91 92 93 94 95 96 |
# File 'lib/lib/user_interface/game_window.rb', line 91 def reset reset! @infopane.reset! @brickyard.reset! @hook.reset! end |
#reset! ⇒ Object
Load default setup
99 100 101 |
# File 'lib/lib/user_interface/game_window.rb', line 99 def reset! @won = false end |
#switch_debug! ⇒ Object
Switch debug flag
104 105 106 |
# File 'lib/lib/user_interface/game_window.rb', line 104 def switch_debug! $debug = !$debug end |
#update ⇒ Object
Process given button
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/lib/user_interface/game_window.rb', line 62 def update @infopane.update unless @won @brickyard.update() @hook.update() check_win end # Stop procsesing this button = nil end |