Class: Infopane
- Inherits:
-
Object
- Object
- Infopane
- Defined in:
- lib/lib/user_interface/infopane.rb
Overview
Score, turn and event texts
Instance Attribute Summary collapse
-
#cursor ⇒ Object
writeonly
Sets the attribute cursor.
-
#faction ⇒ Object
readonly
Returns the value of attribute faction.
-
#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
Increment faction counter (modulo count of factions).
-
#next_turn! ⇒ Object
Increment turn counter.
- #turnscore ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize ⇒ Infopane
Returns a new instance of Infopane.
8 9 10 11 12 13 |
# File 'lib/lib/user_interface/infopane.rb', line 8 def initialize @turn = 0 @faction = FACTIONS # so that FAC1 will be then the first active faction @score = [0, 0] @text = 'ready' end |
Instance Attribute Details
#cursor=(value) ⇒ Object (writeonly)
Sets the attribute cursor
6 7 8 |
# File 'lib/lib/user_interface/infopane.rb', line 6 def cursor=(value) @cursor = value end |
#faction ⇒ Object (readonly)
Returns the value of attribute faction.
5 6 7 |
# File 'lib/lib/user_interface/infopane.rb', line 5 def faction @faction end |
#text=(value) ⇒ Object (writeonly)
Sets the attribute text
6 7 8 |
# File 'lib/lib/user_interface/infopane.rb', line 6 def text=(value) @text = value end |
Instance Method Details
#add_score(to_whom, how_much) ⇒ Object
46 47 48 |
# File 'lib/lib/user_interface/infopane.rb', line 46 def add_score(to_whom, how_much) @score[to_whom] += how_much end |
#draw ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/lib/user_interface/infopane.rb', line 18 def draw freeroam_text = "" freeroam_text = " (freeroam)" if (@cursor and @cursor.freeroam) state = Gosu::Image.from_text(turnscore + freeroam_text, LINE_HEIGHT) state.draw(XTEXT, YTEXT, ZTEXT) text = Gosu::Image.from_text("#{@text}", LINE_HEIGHT) text.draw(XTEXT, (TILESIZE / 2) + YTEXT, ZTEXT) end |
#next_faction! ⇒ Object
Increment faction counter (modulo count of factions)
36 37 38 39 |
# File 'lib/lib/user_interface/infopane.rb', line 36 def next_faction! @faction += 1 @faction = 1 if @faction > FACTIONS # marks the end of turn end |
#next_turn! ⇒ Object
Increment turn counter
42 43 44 |
# File 'lib/lib/user_interface/infopane.rb', line 42 def next_turn! @turn += 1 end |
#turnscore ⇒ Object
29 30 31 32 33 |
# File 'lib/lib/user_interface/infopane.rb', line 29 def turnscore "Turn: #{@turn}, " \ "Faction: FAC#{@faction}, " \ "Score: #{@score[0]} - #{@score[1]}" end |
#update ⇒ Object
15 16 |
# File 'lib/lib/user_interface/infopane.rb', line 15 def update end |