class Chrono

Public Class Methods

new(jeuUI, labelChrono) click to toggle source
# File Core/Chrono.rb, line 15
def initialize(jeuUI, labelChrono)
        @minutes = 0
        @secondes = 0
        @jeuCourant = jeuUI
        @labelChrono = labelChrono
end

Public Instance Methods

activeChrono() click to toggle source
# File Core/Chrono.rb, line 41
def activeChrono()
        if (@active)
                @active = false
        else
                @active = true
        end
end
afficherTps() click to toggle source
# File 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() click to toggle source
# File Core/Chrono.rb, line 59
def lancerChrono()
#Chrono sans arguments
        activeChrono()
        while( (@minutes < 59) && @active )
                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) click to toggle source
# File Core/Chrono.rb, line 77
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) click to toggle source
# File Core/Chrono.rb, line 54
def razChrLbl(chr)
        self.razChrono();
        chr.set_label("00:00")
end
razChrono() click to toggle source
# File Core/Chrono.rb, line 49
def razChrono()
        @minutes = 0;
        @secondes = 0;
end