Class: GamesAndRpgParadise::GardenHero::Menu
- Inherits:
-
Object
- Object
- GamesAndRpgParadise::GardenHero::Menu
- Defined in:
- lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/menu/menu.rb
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
#
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 18 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.
13 14 15 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 13 def display @display end |
Instance Method Details
#draw ⇒ Object
#
draw
#
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 68 69 70 71 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 41 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.
#
120 121 122 123 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 120 def exit @window.pause = true @window.close end |
#new_game ⇒ Object
#
new_game
New game button click event.
#
103 104 105 106 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 103 def new_game @display = false @window.pause = false end |
#reset ⇒ Object
#
reset
#
33 34 35 36 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 33 def reset @display = true @show_controls = false end |
#show_controls ⇒ Object
#
show_controls
#
111 112 113 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 111 def show_controls @show_controls = true end |
#update ⇒ Object
#
update
#
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/menu/menu.rb', line 76 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 |