Gamemaker Studio 2 custom timers?

Started by Amon, November 28, 2018, 15:03:15

Previous topic - Next topic

Amon

Can anybody who uses GMS2 help me with setting up custom timers that work with delta timing code. The delta timing is not the issue it's just that I use alarms in GMS2 and the results when testing on different hardware break my game if the hardware is slower.


I've only just run into this issue and others recommended using custom timers instead of GMS2 inbuilt alarm system.

Amon

#1

ok, I seem to have worked it out. I created a script called scr_delta_alarm. Inside it I put:


/// scr_delta_alarm(n);
n = argument[0];
return n * 1000000;


In my Objects Create Event I put:


delta_alarm = scr_delta_alarm(3);


In the Objects Step event I put Frostys code I found on the forum:


if (delta_alarm > 0) {
delta_alarm -= delta_time;
if (delta_alarm <= 0) {
instance_create_layer(x,y,"Instances",objBullet);
delta_alarm = scr_delta_alarm(3);
}
}


It works lovely. Thanks all.


Xerra

Quote from: Amon. on November 28, 2018, 16:53:21

ok, I seem to have worked it out. I created a script called scr_delta_alarm. Inside it I put:


/// scr_delta_alarm(n);
n = argument[0];
return n * 1000000;


In my Objects Create Event I put:


delta_alarm = scr_delta_alarm(3);


In the Objects Step event I put Frostys code I found on the forum:


if (delta_alarm > 0) {
delta_alarm -= delta_time;
if (delta_alarm <= 0) {
instance_create_layer(x,y,"Instances",objBullet);
delta_alarm = scr_delta_alarm(3);
}
}


I've not used a delta event as yet so I'm curious how much the time differed compared to using the standard alarm events. if you're set to 60fps within GameMakers settings then using alarm(3) would be equivalent to 3 seconds regardless of anything else going on around it. I've used alarms for some simple stuff but only very recently so I'm not claiming that what I'm saying is correct, just my assumption.
M2 Pro Mac mini - 16GB 512 SSD
ACER Nitro 5 15.6" Gaming Laptop - Intel® Core™ i7, RTX 3050, 1 TB SSD
Vic 20 - 3.5k 1mhz 6502

Latest game - https://xerra.itch.io/Gridrunner
Blog: http://xerra.co.uk
Itch.IO: https://xerra.itch.io/