Class: Menu
- Inherits:
-
Object
- Object
- Menu
- Defined in:
- lib/games_paradise/gui/gosu/garden_hero/core/menu/menu.rb
Overview
#
Menu - main menu class
#
Instance Attribute Summary collapse
-
#display ⇒ Object
Returns the value of attribute display.
Instance Method Summary collapse
-
#draw ⇒ Object
# === draw ========================================================================= #.
-
#exit ⇒ Object
# === exit.
-
#initialize(window) ⇒ Menu
constructor
# === initialize ========================================================================= #.
-
#new_game ⇒ Object
# === new_game.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#show_controls ⇒ Object
# === show_controls ========================================================================= #.
-
#update ⇒ Object
# === update ========================================================================= #.
Constructor Details
#initialize(window) ⇒ Menu
#
initialize
#
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 14 def initialize(window) @window = window @bg = Gosu::Image.new('images/menu/menu.png', tileable: true) @cursor = Gosu::Image.new('images/menu/cursor.png') @controls = Gosu::Image.new('images/menu/controls.png') @collect = Gosu::Image.new('images/menu/collect.png') @enemy = Gosu::Image.new('images/menu/enemy.png') @copyright = Gosu::Font.new(window, 'Monospace', 20) @ctrl = Gosu::Font.new(window, 'Monospace', 16) reset end |
Instance Attribute Details
#display ⇒ Object
Returns the value of attribute display.
9 10 11 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 9 def display @display end |
Instance Method Details
#draw ⇒ Object
#
draw
#
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 37 def draw if display @bg.draw 0, 0, 0 @cursor.draw @window.mouse_x, @window.mouse_y, 4 year = (Time.at(Time.now.to_i)).strftime("%Y") @copyright.draw_text("Copyright (c) #{year} by zhzhussupovkz", 175, 450, 1) @copyright.draw_text("Music by Super Mario Bros.", 220, 475, 1) if @show_controls @controls.draw(200, 208, 2) @ctrl.draw_text("CONTROLS", 300, 216, 3) @ctrl.draw_text("Movement:", 240, 240, 3) @ctrl.draw_text("Fire:", 240, 264, 3) @ctrl.draw_text("Pause:", 240, 288, 3) @ctrl.draw_text("Collect ", 240, 324, 3) @collect.draw(336, 322, 3) @ctrl.draw('Kill ', 240, 348, 3) @enemy.draw(336, 346, 3) @ctrl.draw('Arrows', 336, 240, 3) @ctrl.draw("Space", 336, 264, 3) @ctrl.draw("P", 336, 288, 3) @ctrl.draw("Press SPACE to go to the menu", 224, 386, 3) end if @window.win_game @controls.draw(200, 208, 2) @copyright.draw("You have won the game!", 272, 250, 3) @copyright.draw("SCORE:", 300, 275, 3) @copyright.draw("#{@window.total_score}", 320 - ((Math.log10(@window.total_score + 2).to_i) * 8)/2, 300, 3) @copyright.draw("Press ESC to exit from game", 210, 350, 3) end end end |
#exit ⇒ Object
#
exit
exit button click event.
#
116 117 118 119 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 116 def exit @window.pause = true @window.close end |
#new_game ⇒ Object
#
new_game
New game button click event.
#
99 100 101 102 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 99 def new_game @display = false @window.pause = false end |
#reset ⇒ Object
#
reset
#
29 30 31 32 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 29 def reset @display = true @show_controls = false end |
#show_controls ⇒ Object
#
show_controls
#
107 108 109 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 107 def show_controls @show_controls = true end |
#update ⇒ Object
#
update
#
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/games_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 72 def update if @show_controls == false && @window.win_game == false if 270 < @window.mouse_x && @window.mouse_x < 366 && 240 < @window.mouse_y && @window.mouse_y < 272 && (@window. Gosu::MsLeft) new_game elsif 270 < @window.mouse_x && @window.mouse_x < 366 && 290 < @window.mouse_y && @window.mouse_y < 316 && (@window. Gosu::MsLeft) show_controls elsif 270 < @window.mouse_x && @window.mouse_x < 366 && 338 < @window.mouse_y && @window.mouse_y < 362 && (@window. Gosu::MsLeft) exit end end @show_controls = false if @window. Gosu::KbSpace end |