GameMaker Studio 2 Desktop

GameMaker Studio 2 Desktop

Making a chronometer (stopwatch)
Hi, I want to make a chronometer or stopwatch that can meassure splits of seconds


Exapmle:

05:58
05 seconds, 58 decimals of a second

Thank you in advance.


< >
Showing 1-6 of 6 comments
MrDave Apr 27, 2018 @ 4:50pm 
I guess the most precise way to do this is to use delta_time (which gives you the number of micro seconds that have passed each frame) and count them each frame.

This would adjust for lag between frames.

Otherwise you can just use game_get_speed(gamespeed_microseconds) to return the speed of the game in microseconds, again count them up each frame and you know the micro seconds.
◯コンコン Apr 29, 2018 @ 11:58pm 
I did it this way and it worked just fine:

//Create event
global.sec = 0

//step event
global.sec+= (delta_time*0.000001)*room_speed;

//Draw event
draw_text(obj_stopwatch.x,obj.stopwatch.y,string(global.sec div 60) + ":" + string(global.sec mod 60))

Hope it helps someone in the future.
Cat_Craft Apr 10, 2020 @ 3:12am 
How to Stop the Stopwatch?
◯コンコン Apr 10, 2020 @ 6:25pm 
You can create a conditional for the step event:

//step event
if global.stopwatchrunning = true
//step event
global.sec+= (delta_time*0.000001)*room_speed;


So when global.stopwatchrunning is false it wouldn't run.
Cat_Craft Apr 22, 2020 @ 3:14am 
Ok thanks im not so good in gm
Loghy May 17, 2023 @ 7:28pm 
Originally posted by Mr. Tkila:
I did it this way and it worked just fine:

//Create event
global.sec = 0

//step event
global.sec+= (delta_time*0.000001)*room_speed;

//Draw event
draw_text(obj_stopwatch.x,obj.stopwatch.y,string(global.sec div 60) + ":" + string(global.sec mod 60))

Hope it helps someone in the future.
5 years later, it did, Thank you.
< >
Showing 1-6 of 6 comments
Per page: 1530 50