• Welcome to Dark Bit Factory & Gravity.
 

Display Timer - Way to optimize ?

Started by va!n, November 27, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

va!n

i want to display a timer in a game which may look like this:

00:00:00     the 1st 00 block are the minutes, the 2nd 00 block are the seconds and the last are the mseconds.


Now the way i thought how to calculate and draw this timing with formating the string is following but i am not sure if there is a better (optimized and faster) way.


if dig1 = 10 : dig1 = 0 : dig2 + 1 : endif
if dig2 =  6  : dig2 = 0 : dig3 + 1 : endif
if dig3 = 10 : dig3 = 0 : dig4 + 1 : endif
if dig4 =  6  : dig4= 0 : dig5 + 1 : endif
if dig5 = 10  : dig5= 0 : dig6 + 1 : endif
if dig6 =  6  : game_completed=true : endif

dig1 + 1 
DrawString( Str(dig6) + Str(dig5) + ":" + Str(dig4) + Str(dig3) + ":" + Str(dig2) + Str(dig1) )


hope the source is correct, because i typed here while sitting not in front of my pc :P
I still thought if there is another (better and possible faster way) using pointers but i am not really sure atm...

- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Jim

In C, you can do
sprintf(timestring, "%02d:%02d:%02d", hours, minutes, seconds);
In BASIC, try looking up the docs for
Print Using

Jim
Challenge Trophies Won:

va!n

thx. when seeing the c codesnip i like C/CPP ;)
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won: