Class: Chrono
- Inherits:
-
Object
- Object
- Chrono
- Defined in:
- lib/Hashiparmentier/Core/Chrono.rb
Instance Method Summary collapse
- #activeChrono ⇒ Object
- #afficherTps ⇒ Object
-
#initialize(jeuUI, labelChrono) ⇒ Chrono
constructor
A new instance of Chrono.
- #lancerChrono ⇒ Object
- #lancerChrono2(tps, chrono) ⇒ Object
- #razChrLbl(chr) ⇒ Object
- #razChrono ⇒ Object
Constructor Details
#initialize(jeuUI, labelChrono) ⇒ Chrono
Returns a new instance of Chrono.
15 16 17 18 19 20 |
# File 'lib/Hashiparmentier/Core/Chrono.rb', line 15 def initialize(jeuUI, labelChrono) @minutes = 0 @secondes = 0 @jeuCourant = jeuUI @labelChrono = labelChrono end |
Instance Method Details
#activeChrono ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/Hashiparmentier/Core/Chrono.rb', line 41 def activeChrono() if (@active) @active = false else @active = true end end |
#afficherTps ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/Hashiparmentier/Core/Chrono.rb', line 22 def afficherTps() if(@minutes < 10) if(@secondes < 10) @labelChrono.set_label(" 0#{@minutes}:0#{@secondes}") #return ("0#{@minutes}:0#{@secondes}") else @labelChrono.set_label(" 0#{@minutes}:#{@secondes}") #return("0#{@minutes}:#{@secondes}") end else if(@secondes < 10) @labelChrono.set_label("#{@minutes}:0#{@secondes}") #return("#{@minutes}:0#{@secondes}") else @labelChrono.set_label("#{@minutes}:#{@secondes}") #return(#{@minutes}:#{@secondes}" end end end |
#lancerChrono ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/Hashiparmentier/Core/Chrono.rb', line 59 def lancerChrono() #Chrono sans arguments activeChrono() while( (@minutes < 59) && @active ) @jeuCourant.actualiseScore() afficherTps() sleep(1) @secondes += 1 if(@secondes%10 == 0) @jeuCourant.modifScore(-50) end if(@secondes >= 60) @minutes += 1 @secondes = 0 end end #@jeuCourant.setTempsFin(@minutes, @secondes) end |
#lancerChrono2(tps, chrono) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/Hashiparmentier/Core/Chrono.rb', line 78 def lancerChrono2(tps, chrono) #Chrono avec arguments : Durée du Chrono, Label du Chrono self.activeChrono() while( (@minutes < tps) & @active ) chrono.set_label(self.afficherTps()) sleep(1) @secondes += 1 if(@secondes >= 60) @minutes += 1 @secondes = 0 end end end |
#razChrLbl(chr) ⇒ Object
54 55 56 57 |
# File 'lib/Hashiparmentier/Core/Chrono.rb', line 54 def razChrLbl(chr) self.razChrono(); chr.set_label("00:00") end |
#razChrono ⇒ Object
49 50 51 52 |
# File 'lib/Hashiparmentier/Core/Chrono.rb', line 49 def razChrono() @minutes = 0; @secondes = 0; end |