Class: SpaceInvaders::ScoreTracker
- Defined in:
- lib/space_invaders/trackers/score_tracker.rb
Instance Attribute Summary collapse
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Attributes inherited from Base
Instance Method Summary collapse
- #draw ⇒ Object
- #increase_by(number) ⇒ Object
-
#initialize(app) ⇒ ScoreTracker
constructor
A new instance of ScoreTracker.
- #set_score_number ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(app) ⇒ ScoreTracker
Returns a new instance of ScoreTracker.
6 7 8 9 10 11 |
# File 'lib/space_invaders/trackers/score_tracker.rb', line 6 def initialize app @app = app @score = 0 @score_headline = Gosu::Image.from_text @app, "Score:", App::DEFAULT_FONT, 30 set_score_number end |
Instance Attribute Details
#score ⇒ Object (readonly)
Returns the value of attribute score.
4 5 6 |
# File 'lib/space_invaders/trackers/score_tracker.rb', line 4 def score @score end |
Instance Method Details
#draw ⇒ Object
22 23 24 25 |
# File 'lib/space_invaders/trackers/score_tracker.rb', line 22 def draw @score_headline.draw 10, 10, 1 @score_number.draw 100, 10, 1, 1, 1, Gosu::Color::GREEN end |
#increase_by(number) ⇒ Object
13 14 15 16 |
# File 'lib/space_invaders/trackers/score_tracker.rb', line 13 def increase_by number @score += number set_score_number end |
#set_score_number ⇒ Object
18 19 20 |
# File 'lib/space_invaders/trackers/score_tracker.rb', line 18 def set_score_number @score_number = Gosu::Image.from_text @app, @score, App::DEFAULT_FONT, 30 end |