Author Topic: Gamemaker Studio 2 custom timers?  (Read 439 times)

Offline Amon.

  • Jr. Member
  • **
  • Posts: 63
  • What? There's no ceiling outside?
    • Amon.Pro
Gamemaker Studio 2 custom timers?
« on: November 28, 2018, 03:03:15 PM »
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.
Windows 10 Pro - 32GB DDR4 RAM - GEFORCE GTX 1080 8GB - OCTACORE AMD FX 3.8GHZ - WATERCOOLING.

Offline Amon.

  • Jr. Member
  • **
  • Posts: 63
  • What? There's no ceiling outside?
    • Amon.Pro
Re: Gamemaker Studio 2 custom timers?
« Reply #1 on: November 28, 2018, 04:53:21 PM »
Code: [Select]
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.

Windows 10 Pro - 32GB DDR4 RAM - GEFORCE GTX 1080 8GB - OCTACORE AMD FX 3.8GHZ - WATERCOOLING.

Offline Xerra

  • Sr. Member
  • ****
  • Posts: 304
    • Retro Evolved
Re: Gamemaker Studio 2 custom timers?
« Reply #2 on: November 28, 2018, 05:26:24 PM »
Code: [Select]
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.