Class: GamesAndRpgParadise::GameWindow
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- GamesAndRpgParadise::GameWindow
- Defined in:
- lib/games_and_rpg_paradise/gui/gosu/battle_city/window.rb,
lib/games_and_rpg_paradise/games/flappy_bird/gosu/flappy.rb
Constant Summary collapse
- TITLE =
#
TITLE
#
'Battle City'
Instance Attribute Summary collapse
-
#delta ⇒ Object
Returns the value of attribute delta.
-
#entities ⇒ Object
Returns the value of attribute entities.
-
#game_running ⇒ Object
Returns the value of attribute game_running.
-
#walls ⇒ Object
Returns the value of attribute walls.
Instance Method Summary collapse
-
#button_down(id) ⇒ Object
# === button_down ========================================================================= #.
-
#draw ⇒ Object
# === draw.
-
#ground_height ⇒ integer
# === ground_height.
-
#ground_y ⇒ Object
# === ground_y.
-
#initialize ⇒ GameWindow
constructor
# === initialize.
-
#reset ⇒ Object
# === reset.
-
#sky_height ⇒ integer
# === sky_height.
-
#update ⇒ Object
Update game for each loop occurence - standard gosu method.
-
#update_delta ⇒ Object
update_delta.
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, #set_font, #set_title, #sqrt, #tab_key?, #write_this_text
Constructor Details
#initialize ⇒ GameWindow
#
initialize
Initialize the game
#
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/window.rb', line 19 def initialize super(800, 710, false) self.caption = TITLE @text_display = Gosu::Font.new(self, 'FUTURA', 50) @theme_music = Gosu::Song.new("media/magic_space.mp3") @theme_music.play(true) @theme_music.volume = 0.2 @game_over_music = Gosu::Song.new("media/game_over.wav") @game_over_music.volume = 0.2 @player = Player.new(self) @game_running = true @game_win_music = Gosu::Song.new("media/game_win.mp3") @game_win_music.volume = 0.2 end |
Instance Attribute Details
#delta ⇒ Object
Returns the value of attribute delta.
19 20 21 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/flappy.rb', line 19 def delta @delta end |
#entities ⇒ Object
Returns the value of attribute entities.
17 18 19 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/flappy.rb', line 17 def entities @entities end |
#game_running ⇒ Object
Returns the value of attribute game_running.
9 10 11 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/window.rb', line 9 def game_running @game_running end |
#walls ⇒ Object
Returns the value of attribute walls.
18 19 20 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/flappy.rb', line 18 def walls @walls end |
Instance Method Details
#button_down(id) ⇒ Object
#
button_down
#
44 45 46 47 48 49 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/window.rb', line 44 def (id) case id when Gosu::KB_ESCAPE close end end |
#draw ⇒ Object
#
draw
Draw entities of games - this is a standard gosu method.
#
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/window.rb', line 73 def draw @player.draw unless @game_running if @player.win @text_display.draw_text("YOU WON!", 300, 305, 3, 1, 1, Gosu::Color::CYAN) else @text_display.draw_text("GAME OVER", 296, 305, 3, 1, 1, Gosu::Color::CYAN) end end end |
#ground_height ⇒ integer
#
ground_height
Return the height of ground
#
131 132 133 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/flappy.rb', line 131 def ground_height @ground.height end |
#ground_y ⇒ Object
#
ground_y
Return ground y position
#
142 143 144 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/flappy.rb', line 142 def ground_y @ground.y end |
#reset ⇒ Object
#
reset
Reset all elements
#
37 38 39 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/window.rb', line 37 def reset @game_over_music_played = false end |
#sky_height ⇒ integer
#
sky_height
Compute height of sky
#
121 122 123 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/flappy.rb', line 121 def sky_height @background_image.height - self.ground_height end |
#update ⇒ Object
Update game for each loop occurence - standard gosu method
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/games_and_rpg_paradise/gui/gosu/battle_city/window.rb', line 54 def update if @game_running @player.update else @theme_music.pause if @player.win @game_win_music.play else unless @game_over_music_played @game_over_music.play @game_over_music_played = true end end end end |
#update_delta ⇒ Object
update_delta
Update delta param
68 69 70 71 72 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/flappy.rb', line 68 def update_delta current_time = ::Gosu.milliseconds / 1000.0 @delta = [current_time - @last_time, 0.25].min @last_time = current_time end |