Class: Infopane
- Inherits:
-
Object
- Object
- Infopane
- Defined in:
- lib/lib/user_interface/infopane.rb
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(window) ⇒ Infopane
constructor
A new instance of Infopane.
-
#reset! ⇒ Object
Load default setup.
- #update ⇒ Object
Constructor Details
#initialize(window) ⇒ Infopane
Returns a new instance of Infopane.
4 5 6 7 |
# File 'lib/lib/user_interface/infopane.rb', line 4 def initialize(window) @window = window reset! end |
Instance Attribute Details
#time ⇒ Object (readonly)
Returns the value of attribute time.
2 3 4 |
# File 'lib/lib/user_interface/infopane.rb', line 2 def time @time end |
Instance Method Details
#draw ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lib/user_interface/infopane.rb', line 21 def draw text = "#{@time}s" if @window.win text += "\nBackspace to restart" end text = Gosu::Image.from_text( text, LINE_HEIGHT, {:width => WINDOW_WIDTH, :align => :center} ) text.draw(0, 0, ZTEXT) end |
#reset! ⇒ Object
Load default setup
10 11 12 13 |
# File 'lib/lib/user_interface/infopane.rb', line 10 def reset! @starttime = Gosu.milliseconds @time = 0 end |
#update ⇒ Object
15 16 17 18 19 |
# File 'lib/lib/user_interface/infopane.rb', line 15 def update() unless @window.win @time = (Gosu.milliseconds - @starttime) / 1000.0 end end |