BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"Digital Countdown Timer"
, by kryten
A digital countdown timer displaying minutes, seconds and tenths of a second.
Code
AppTitle "Countdown Timer" ;Digital Countdown Timer ;Created by Kryten ;11th July 2003 ;## SET GFX MODE ## Graphics 640,480 ;## SET TIMER VARIABLES ## Global countdown=3600000;Set to sixty minutes ( 1 sec = 1000 millisecs) ;this is the countdown figure Global starttime=0 ;Current system time at timer initiation Global elapsed=0 ;Elapsed time Global minutes=0 ;Variable to hold minutes conversion Global seconds=0 ;Variable to hold seconds conversion Global tenths=0 ;Variable to hold 1/10 of a second conversion Global initiatetimer=0 ;Variable to initiate timer SetBuffer BackBuffer() ;Set the buffer ;## MAIN LOOP ## While Not KeyDown(1) Cls If initiatetimer=0 Then start() If countdown>0 Then calctimer() Text 0,0,"Timer : "+minutes +" : "+seconds +" : "+tenths Flip Wend ;## FUNCTIONS ## ;This function starts the timer itself Function start() starttime=MilliSecs() ;Get the current system time in milliseconds initiatetimer=1 ;Set the initate variable to 1 so that we dont run this function again End Function ;This function works out the elapsed time and conversion to minutes / seconds / tenths Function calctimer() elapsed=MilliSecs()-starttime ;Work out elapsed time starttime=MilliSecs() ;Make the starttime the current system time (resetting it) countdown=countdown-elapsed ;Subtract elapsed time from the countdown timer variable elapsed=0 ;Reset elapsed time variable If countdown<=0 Then countdown=0 ;Check to see If timer has reached zero ;conversion minutes=countdown/60000 ;Convert countdown timer to minutes seconds=(countdown-(minutes*60000))/1000 ;Subtract minutes from timer and convert remainder to seconds tenths=(countdown-(minutes*60000)-(seconds*1000))/100 ;and again for tenths of a second ;Note: if you need tenths to show as double figures ;then divide by 10 instead of 100 End Function
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations