Class: Rubygoal::Game
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- Rubygoal::Game
- Extended by:
- Forwardable
- Defined in:
- lib/rubygoal/game.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#score_away ⇒ Object
readonly
Returns the value of attribute score_away.
-
#score_home ⇒ Object
readonly
Returns the value of attribute score_home.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #button_down(id) ⇒ Object
- #draw ⇒ Object
-
#initialize ⇒ Game
constructor
A new instance of Game.
- #update ⇒ Object
Constructor Details
#initialize ⇒ Game
Returns a new instance of Game.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rubygoal/game.rb', line 16 def initialize super(1920, 1080, true) self.caption = "Ruby Goal" @field = Field.new(self) @goal = Goal.new(self) @state = :playing @time = Config.game.time @score_home = 0 @score_away = 0 @font = Gosu::Font.new( self, Gosu.default_font_name, Config.game.default_font_size ) @home_team_label = create_label_image(name_home) @away_team_label = create_label_image(name_away) end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
11 12 13 |
# File 'lib/rubygoal/game.rb', line 11 def field @field end |
#score_away ⇒ Object
Returns the value of attribute score_away.
11 12 13 |
# File 'lib/rubygoal/game.rb', line 11 def score_away @score_away end |
#score_home ⇒ Object
Returns the value of attribute score_home.
11 12 13 |
# File 'lib/rubygoal/game.rb', line 11 def score_home @score_home end |
#time ⇒ Object
Returns the value of attribute time.
11 12 13 |
# File 'lib/rubygoal/game.rb', line 11 def time @time end |
Instance Method Details
#button_down(id) ⇒ Object
61 62 63 64 65 |
# File 'lib/rubygoal/game.rb', line 61 def (id) if id == Gosu::KbEscape close end end |
#draw ⇒ Object
54 55 56 57 58 59 |
# File 'lib/rubygoal/game.rb', line 54 def draw field.draw draw_scoreboard draw_team_labels goal.draw if field.goal? end |
#update ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rubygoal/game.rb', line 39 def update return if state == :ended update_elapsed_time if field.goal? update_goal else update_remaining_time field.update end end_match! if time <= 0 end |