Class: Infopane
- Inherits:
-
Object
- Object
- Infopane
- Defined in:
- lib/infopane.rb
Overview
Score, turn and event texts
Instance Attribute Summary collapse
-
#act_fact ⇒ Object
writeonly
Sets the attribute act_fact.
-
#text ⇒ Object
writeonly
Sets the attribute text.
Instance Method Summary collapse
- #add_score(to_whom, how_much) ⇒ Object
- #draw ⇒ Object
-
#initialize ⇒ Infopane
constructor
A new instance of Infopane.
- #next_faction ⇒ Object
- #next_turn ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize ⇒ Infopane
Returns a new instance of Infopane.
5 6 7 8 9 10 |
# File 'lib/infopane.rb', line 5 def initialize @score = [0, 0] @turn = 0 @act_fact = 0 # active faction @text = 'ready' end |
Instance Attribute Details
#act_fact=(value) ⇒ Object (writeonly)
Sets the attribute act_fact
3 4 5 |
# File 'lib/infopane.rb', line 3 def act_fact=(value) @act_fact = value end |
#text=(value) ⇒ Object (writeonly)
Sets the attribute text
3 4 5 |
# File 'lib/infopane.rb', line 3 def text=(value) @text = value end |
Instance Method Details
#add_score(to_whom, how_much) ⇒ Object
33 34 35 |
# File 'lib/infopane.rb', line 33 def add_score(to_whom, how_much) @score[to_whom] += how_much end |
#draw ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/infopane.rb', line 15 def draw turnscore = Gosu::Image.from_text( self, "Turn: #{@turn}, Score: #{@score[0]} - #{@score[1]}", Gosu.default_font_name, 20) turnscore.draw(XTEXT, YTEXT, ZTEXT) text = Gosu::Image.from_text(self, "#{@text}", Gosu.default_font_name, 20) text.draw(XTEXT, (TILESIZE / 2) + YTEXT, ZTEXT) end |
#next_faction ⇒ Object
24 25 26 |
# File 'lib/infopane.rb', line 24 def next_faction end |
#next_turn ⇒ Object
28 29 30 31 |
# File 'lib/infopane.rb', line 28 def next_turn @turn += 1 puts "Turn: #{@turn}, Score: #{@score[0]} - #{@score[1]}" end |
#update ⇒ Object
12 13 |
# File 'lib/infopane.rb', line 12 def update end |