Legacy GM Simple Stopwatch/Timer

J

John Assounga

Guest
Hi Guys,

I'm making a simple racing game and I would like to know how to display a stopwatch.
It can literally just start from 0:00:00 and go up, no fancy sprites.

I've looked all over and a lot of people seem to be doing a countdown timer but not a stopwatch, could anyone help me out please.

Regards!
 

Morseton

Member
create event:
minutes = 0;
seconds = 0;
steps = 0;

step event:
steps += 1;
if steps >= room_speed
{
steps = 0;
seconds += 1;

if seconds >= 60
{
seconds = 0;
minutes += 1;
}
}

this can give you an idea how to make a stopwatch
 
T

tienhagioi

Guest
create event :
secs = 0

step event :

secs+= (delta_time/1000000)*room_speed

draw event :

draw_text (x,y , string(secs div 3600) + ":" + string(secs div 60) + ":" + string(secs mod 60))
Use delta_time , your timer more exactly
 
T

The Shatner

Guest
tienhagioi is totally right, if you don't use delta_time your timer may have a "delay with real life", because the hardware may sometimes fail to deliver fps = room_speed. Delta-timing is essential!
I'd just like to add that, according to the optimization guide, GM actually does multiplication faster than division, so if your game is going to have a lot of processing, maybe you could make it like this:
Code:
secs += (delta_time*0.000001)*room_speed;
 
B

BlueDeath

Guest
A question about delta_time. Can I use it to measure the seconds (well...miliseconds) between two event?
 
R

Remix The Idiot

Guest
how do we show the timer? Like on the upper left of the screen per say.
 
F

Faceater

Guest
Hello, thank you very much ! This was very helpful for a newbie like me.

Is there a way to make the timer keep running through certain rooms ?

thank you
 
Top