Unnütze Stoppuhr und Countdown Engine
Übersicht

![]() |
nX^Betreff: Unnütze Stoppuhr und Countdown Engine |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ich hatte heute Langeweile gehabt und eine kleine unnütze Engine geschrieben. Sie beinhaltet viele Funktionen zum Erstellen und kontrolieren einer Stoppuhr oder eines Countdowns.
Beispiel: Code: [AUSKLAPPEN] Graphics 800,600,32,2
SetBuffer BackBuffer() SX_CreateTimer(0,0,"",1,0,0,0,"",0,0,0,255,255,255,0) SX_CreateCountDown(5,5,"CountDown: ",1,15,0,0,"Arial",20,0,0,255,255,255) Repeat Cls SX_UpdateEngine() wert = SX_GetCDSec(1) If wert <= 0 Then Cls Print "Bitte Taste drücken." WaitKey() wert2 = SX_GetTSec(1) Print "Das Programm wurde "+wert2+" Sekunden benutzt." Delay 2000 End EndIf Flip Forever Engine: Code: [AUSKLAPPEN] Type CountDown
Field x Field y Field sec Field min Field hour Field ID Field UserID Field timer Field txt$ Field font Field r Field g Field b Field show Field activ End Type Type Timer Field x Field y Field sec Field min Field hour Field ID Field UserID Field timer Field txt$ Field font Field r Field g Field b Field show Field activ End Type Function SX_CreateCountDown(x,y,txt$,UserID,sec,min=0,hour=0,f$="",f1=0,f2=0,f3=0,r=0,g=0,b=0,s=1,a=1) c.CountDown = New CountDown c\x = x c\y = y c\sec = sec c\min = min c\hour = hour c\ID = Handle(c) c\UserID = UserID c\timer = MilliSecs() c\txt$ = txt$ If f$ <> "" Or f$ <> " " Then c\font = LoadFont(f$,f1,f2,f3) EndIf c\r = r c\g = g c\b = b c\show = s c\activ = a End Function Function SX_CreateTimer(x,y,txt$,UserID,sec=0,min=0,hour=0,f$="",f1=0,f2=0,f3=0,r=0,g=0,b=0,s=1,a=1) t.Timer = New Timer t\x = x t\y = y t\sec = sec t\min = min t\hour = hour t\ID = Handle(t) t\UserID = UserID t\timer = MilliSecs() t\txt$ = txt$ If f$ <> "" Or f$ <> " " Then t\font = LoadFont(f$,f1,f2,f3) EndIf t\r = r t\g = g t\b = b t\show = s t\activ = a End Function Function SX_UpdateEngine() For c.CountDown = Each CountDown If c\activ = 1 If MilliSecs()-c\timer>=1*1000 If c\hour >= 0 Then If c\min >= 0 Then If c\sec >= 1 Then c\sec = c\sec - 1 EndIf EndIf EndIf If c\min > 0 Then If c\sec <= 0 Then c\min = c\min - 1 c\sec = 59 EndIf EndIf If c\hour > 0 Then If c\min <= 0 Then c\hour = c\hour - 1 c\min = 59 EndIf EndIf c\timer = MilliSecs() EndIf EndIf If c\hour <= 9 Then tmp1$ = 0 If c\min <= 9 Then tmp2$ = 0 If c\sec <= 9 Then tmp3$ = 0 If c\show = 1 Then SetFont c\font Color c\r,c\g,c\b Text c\x,c\y,c\txt$+tmp1$+c\hour+":"+tmp2$+c\min+":"+tmp3$+c\sec Color 255,255,255 EndIf Next For t.Timer = Each Timer If t\activ = 1 If MilliSecs()-t\timer>=1*1000 Then t\sec = t\sec + 1 If t\sec >= 59 Then t\min = t\min + 1 t\sec = 0 EndIf If t\min >= 59 Then t\hour = t\hour + 1 t\min = 0 EndIf t\timer = MilliSecs() EndIf EndIf If t\hour <= 9 Then tmp1$ = 0 If t\min <= 9 Then tmp2$ = 0 If t\sec <= 9 Then tmp3$ = 0 If t\show = 1 Then SetFont t\font Color t\r,t\g,t\b Text t\x,t\y,t\txt$+tmp1$+t\hour+":"+tmp2$+t\min+":"+tmp3$+t\sec Color 255,255,255 EndIf Next End Function Function SX_GetCDTime$(UserID) For c.CountDown = Each CountDown If c\UserID = UserID Then If c\hour <= 9 Then tmp1$ = 0 If c\min <= 9 Then tmp2$ = 0 If c\sec <= 9 Then tmp3$ = 0 msg$ = tmp1$+c\hour+":"+tmp2$+c\min+":"+tmp3$+c\sec Return msg$ EndIf Next End Function Function SX_GetCDSec(UserID) For c.CountDown = Each CountDown If c\UserID = UserID Then Return c\sec Next End Function Function SX_GetCDMin(UserID) For c.CountDown = Each CountDown If c\UserID = UserID Then Return c\min Next End Function Function SX_GetCDHour(UserID) For c.CountDown = Each CountDown If c\UserID = UserID Then Return c\hour Next End Function Function SX_GetTTime$(UserID) For t.Timer = Each Timer If t\UserID = UserID Then If t\hour <= 9 Then tmp1$ = 0 If t\min <= 9 Then tmp2$ = 0 If t\sec <= 9 Then tmp3$ = 0 msg$ = tmp1$+t\hour+":"+tmp2$+t\min+":"+tmp3$+t\sec Return msg$ EndIf Next End Function Function SX_GetTSec(UserID) For t.Timer = Each Timer If t\UserID = UserID Then Return t\sec Next End Function Function SX_GetTMin(UserID) For t.Timer = Each Timer If t\UserID = UserID Then Return t\min Next End Function Function SX_GetTHour(UserID) For t.Timer = Each Timer If t\UserID = UserID Then Return t\hour Next End Function Function SX_DeleteCountDown(UserID) For c.CountDown = Each CountDown If c\UserID = UserID Then Delete c Next End Function Function SX_DeleteTimer(UserID) For t.Timer = Each Timer If t\UserID = UserID Then Delete t Next End Function Function SX_ChangeCDPos(UserID,x,y) For c.CountDown = Each CountDown If c\UserID = UserID Then c\x = x c\y = y EndIf Next End Function Function SX_ChangeCDText(UserID,txt$) For c.CountDown = Each CountDown If c\UserID = UserID Then c\txt$ = txt$ EndIf Next End Function Function SX_ChangeCDTime(UserID,sec,min,hour) For c.CountDown = Each CountDown If c\UserID = UserID Then c\sec = sec c\min = min c\hour = hour EndIf Next End Function Function SX_ChangeCDFont(UserID,font$,f1=0,f2=0,f3=0) For c.CountDown = Each CountDown If c\UserID = UserID Then c\font = LoadFont(font$,f1,f2,f3) EndIf Next End Function Function SX_ChangeCDColor(UserID,r,g,b) For c.CountDown = Each CountDown If c\UserID = UserID Then c\r = r c\g = g c\b = b EndIf Next End Function Function SX_ChangeTPos(UserID,x,y) For t.Timer = Each Timer If t\UserID = UserID Then t\x = x t\y = y EndIf Next End Function Function SX_ChangeTText(UserID,txt$) For t.Timer = Each Timer If t\UserID = UserID Then t\txt$ = txt$ EndIf Next End Function Function SX_ChangeTTime(UserID,sec,min,hour) For t.Timer = Each Timer If t\UserID = UserID Then t\sec = sec t\min = min t\hour = hour EndIf Next End Function Function SX_ChangeTFont(UserID,font$,f1=0,f2=0,f3=0) For t.Timer = Each Timer If t\UserID = UserID Then t\font = LoadFont(font$,f1,f2,f3) EndIf Next End Function Function SX_ChangeTColor(UserID,r,g,b) For t.Timer = Each Timer If t\UserID = UserID Then t\r = r t\g = g t\b = b EndIf Next End Function Function SX_ResetTimer(UserID) For t.Timer = Each Timer If t\UserID = UserID Then t\sec = 0 t\min = 0 t\hour = 0 EndIf Next End Function Function SX_WaitCD(UserID) For c.CountDown = Each CountDown If c\UserID = UserID Then c\activ = 0 EndIf Next End Function Function SX_StartCD(UserID) For c.CountDown = Each CountDown If c\UserID = UserID Then c\activ = 1 EndIf Next End Function Function SX_ShowCD(UserID) For c.CountDown = Each CountDown If c\UserID = UserID Then c\show = 1 EndIf Next End Function Function SX_HideCD(UserID) For c.CountDown = Each CountDown If c\UserID = UserID Then c\show = 0 EndIf Next End Function Function SX_WaitT(UserID) For t.Timer = Each Timer If t\UserID = UserID Then t\activ = 0 EndIf Next End Function Function SX_StartT(UserID) For t.Timer = Each Timer If t\UserID = UserID Then t\activ = 1 EndIf Next End Function Function SX_ShowT(UserID) For t.Timer = Each Timer If t\UserID = UserID Then t\show = 1 EndIf Next End Function Function SX_HideT(UserID) For t.Timer = Each Timer If t\UserID = UserID Then t\show = 0 EndIf Next End Function |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group