Class: Rubygoal::Field
- Inherits:
-
Object
- Object
- Rubygoal::Field
- Extended by:
- Forwardable
- Defined in:
- lib/rubygoal/field.rb
Instance Attribute Summary collapse
-
#ball ⇒ Object
readonly
Returns the value of attribute ball.
-
#team_away ⇒ Object
readonly
Returns the value of attribute team_away.
-
#team_home ⇒ Object
readonly
Returns the value of attribute team_home.
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(game_window) ⇒ Field
constructor
A new instance of Field.
- #reinitialize ⇒ Object
- #team_names ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(game_window) ⇒ Field
Returns a new instance of Field.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rubygoal/field.rb', line 19 def initialize(game_window) @game_window = game_window @background_image = Gosu::Image.new(game_window, Config.field.background_image_file, true) @ball = Ball.new(game_window, FieldMetrics.center_position) coach_home = CoachLoader.get(CoachHome) coach_away = CoachLoader.get(CoachAway) puts "Home coach: #{coach_home.class.name}" puts "Away coach: #{coach_away.class.name}" @team_home = Team.new(game_window, :home, coach_home) @team_away = Team.new(game_window, :away, coach_away) end |
Instance Attribute Details
#ball ⇒ Object (readonly)
Returns the value of attribute ball.
14 15 16 |
# File 'lib/rubygoal/field.rb', line 14 def ball @ball end |
#team_away ⇒ Object (readonly)
Returns the value of attribute team_away.
14 15 16 |
# File 'lib/rubygoal/field.rb', line 14 def team_away @team_away end |
#team_home ⇒ Object (readonly)
Returns the value of attribute team_home.
14 15 16 |
# File 'lib/rubygoal/field.rb', line 14 def team_home @team_home end |
Instance Method Details
#draw ⇒ Object
54 55 56 57 58 59 |
# File 'lib/rubygoal/field.rb', line 54 def draw background_image.draw(0, 0, 0); ball.draw team_home.draw team_away.draw end |
#reinitialize ⇒ Object
35 36 37 38 39 |
# File 'lib/rubygoal/field.rb', line 35 def reinitialize team_home.players_to_initial_position team_away.players_to_initial_position ball.position = FieldMetrics.center_position end |
#team_names ⇒ Object
41 42 43 44 45 46 |
# File 'lib/rubygoal/field.rb', line 41 def team_names { home: team_home.name, away: team_away.name } end |
#update ⇒ Object
48 49 50 51 52 |
# File 'lib/rubygoal/field.rb', line 48 def update team_home.update(game_data(:home)) team_away.update(game_data(:away)) ball.update end |