Class: GamesAndRpgParadise::GardenHero::GameWindow

Inherits:
Gosu::Window
  • Object
show all
Includes:
Singleton
Defined in:
lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/game_window.rb

Overview

GamesAndRpgParadise::GardenHero::GameWindow

Constant Summary collapse

TITLE =
#

TITLE

#
'Garden Hero'

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#initializeGameWindow

#

initialize

#


30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/game_window.rb', line 30

def initialize
  super(640, 504, false)
  self.caption = TITLE
  begin
    @level = Level.new self
    @menu = Menu.new self
    @pause, @win_game = true, false
    @total_score = 0
  rescue Exception => e
    puts "#{e.class}: #{e.message}"
  end
end

Instance Attribute Details

#pauseObject

Returns the value of attribute pause.



23
24
25
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/game_window.rb', line 23

def pause
  @pause
end

#total_scoreObject

Returns the value of attribute total_score.



24
25
26
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/game_window.rb', line 24

def total_score
  @total_score
end

#win_gameObject

Returns the value of attribute win_game.



25
26
27
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/game_window.rb', line 25

def win_game
  @win_game
end

Instance Method Details

#button_down(key) ⇒ Object

button down event



68
69
70
71
72
73
74
75
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/game_window.rb', line 68

def button_down(key)
  case key
  when Gosu::KbEscape
    close
  when Gosu::KbP
    @pause = !@pause if @menu.display === false
  end
end

#drawObject

#

draw

#


53
54
55
56
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/game_window.rb', line 53

def draw
  @menu.draw
  @level.draw if @menu.display === false
end

#level?Boolean Also known as: level

#

level?

#

Returns:

  • (Boolean)


46
47
48
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/game_window.rb', line 46

def level?
  @level
end

#updateObject

#

update

#


61
62
63
64
65
# File 'lib/games_and_rpg_paradise/gui/gosu/garden_hero/core/game_window.rb', line 61

def update
  @menu.display = true if win_game
  @menu.update if pause || win_game
  @level.update if not pause && win_game == false
end