Class: GameWindow
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- GameWindow
- Includes:
- Singleton
- Defined in:
- lib/games_paradise/gui/gosu/chinguroids/chinguroids.rb,
lib/games_paradise/gui/gosu/garden_hero/core/game_window.rb
Overview
#
GameWindow - main window class
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#pause ⇒ Object
Returns the value of attribute pause.
-
#total_score ⇒ Object
Returns the value of attribute total_score.
-
#win_game ⇒ Object
Returns the value of attribute win_game.
Instance Method Summary collapse
-
#button_down(key) ⇒ Object
button down event.
-
#draw ⇒ Object
draw.
-
#initialize ⇒ GameWindow
constructor
initialize.
-
#log ⇒ Object
log.
-
#pop ⇒ Object
pop.
-
#setup ⇒ Object
setup.
-
#update ⇒ Object
update.
Methods inherited from Gosu::Window
#gosu_button_down?, #image, #image10?, #image1?, #image2?, #image3?, #image4?, #image5?, #image6?, #image7?, #image8?, #image9?, #on_left_arrow_pressed?, #on_right_arrow_pressed?, #q_means_quit, #reset, #set_font, #set_title, #sqrt, #tab_key?, #write_this_text
Constructor Details
#initialize ⇒ GameWindow
initialize
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/games_paradise/gui/gosu/chinguroids/chinguroids.rb', line 30 def initialize super(800,600,false) $intro = true # start out by defining some constants used later in the game $max_x = 815 $max_y = 615 $scr_edge = 15 $cooling_down = 70 $star_grab = Sound["media/audio/star_pickup.ogg"] $power_up = Sound["media/audio/power_up.ogg"] self.caption = 'ChinguRoids' @cursor = true # false hides cursor self.input = { :esc => :exit, # global controls [:q, :l] => :pop, :z => :log, :r => lambda{current_game_state.setup} } retrofy # use retrofy for improved scaling of images end |
Instance Attribute Details
#level ⇒ Object (readonly)
Returns the value of attribute level.
23 24 25 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/game_window.rb', line 23 def level @level end |
#pause ⇒ Object
Returns the value of attribute pause.
24 25 26 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/game_window.rb', line 24 def pause @pause end |
#total_score ⇒ Object
Returns the value of attribute total_score.
24 25 26 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/game_window.rb', line 24 def total_score @total_score end |
#win_game ⇒ Object
Returns the value of attribute win_game.
24 25 26 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/game_window.rb', line 24 def win_game @win_game end |
Instance Method Details
#button_down(key) ⇒ Object
button down event
40 41 42 43 44 45 46 47 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/game_window.rb', line 40 def (key) case key when Gosu::KbEscape close when Gosu::KbP @pause = !@pause if @menu.display === false end end |
#draw ⇒ Object
draw
27 28 29 30 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/game_window.rb', line 27 def draw @menu.draw @level.draw if @menu.display === false end |
#log ⇒ Object
log
pressing āzā at any time returns name of current gamestate.
57 58 59 |
# File 'lib/games_paradise/gui/gosu/chinguroids/chinguroids.rb', line 57 def log puts $window.current_game_state end |
#pop ⇒ Object
pop
62 63 64 65 66 67 68 |
# File 'lib/games_paradise/gui/gosu/chinguroids/chinguroids.rb', line 62 def pop # pressing 'q' or 'l' at any time backs out of current gamestate if $window.current_game_state.to_s == "Introduction" or $window.current_game_state.to_s == "Level_1" then pop_game_state(setup: true) elsif $window.current_game_state.to_s != "OpeningCredits" pop_game_state(setup: false) end end |
#setup ⇒ Object
setup
50 51 52 |
# File 'lib/games_paradise/gui/gosu/chinguroids/chinguroids.rb', line 50 def setup push_game_state(Beginning) # start by pushing Beginning gamestate end |
#update ⇒ Object
update
33 34 35 36 37 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/game_window.rb', line 33 def update @menu.display = true if win_game @menu.update if pause || win_game @level.update if not pause && win_game == false end |