• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Delta Time Alarms

G

Greg5000

Guest
Okay, so I have recently got my game to a point where it is near completion and have been in the process of testing it on weaker computers to get a flavour of how it will perform. On my i7 laptop with a GTX960 graphics card it runs at a solid 200-300 FPS, this is good. However on other computers I notice it varies greatly with some noticeable lag.

As such I think a bit of delta_time is in order to make sure users don't get a terrible laggy experience. I have integrated delta_time successfully into all movement and character animations, however I have a lot of alarms to configure.

As alarms count down at a rate of -1 per step I added some code to the step event as follows:

if alarm[0] != -1
{
alarm[0] ++;
alarm[0] -= global.delta;
}

The above makes perfect sense in my head.. each step the alarm depreciates by 1, this 1 is then added back on (effectively pausing the alarm) and then the alarm subtracts 1 multiplied by my delta variable (which works a treat for movement so I know I have coded this correctly). However in practice the alarm simply seems to be paused.

Can anyone think why the above would not be working? I've read that when using delta_time you have to use a custom alarm system.. but I don't see why my work-around falls flat?

Thanks.
 

jo-thijs

Member
Okay, so I have recently got my game to a point where it is near completion and have been in the process of testing it on weaker computers to get a flavour of how it will perform. On my i7 laptop with a GTX960 graphics card it runs at a solid 200-300 FPS, this is good. However on other computers I notice it varies greatly with some noticeable lag.

As such I think a bit of delta_time is in order to make sure users don't get a terrible laggy experience. I have integrated delta_time successfully into all movement and character animations, however I have a lot of alarms to configure.

As alarms count down at a rate of -1 per step I added some code to the step event as follows:

if alarm[0] != -1
{
alarm[0] ++;
alarm[0] -= global.delta;
}

The above makes perfect sense in my head.. each step the alarm depreciates by 1, this 1 is then added back on (effectively pausing the alarm) and then the alarm subtracts 1 multiplied by my delta variable (which works a treat for movement so I know I have coded this correctly). However in practice the alarm simply seems to be paused.

Can anyone think why the above would not be working? I've read that when using delta_time you have to use a custom alarm system.. but I don't see why my work-around falls flat?

Thanks.
Alarms only hold integer values as optimization.
When trying to assign them a number with decimals, the number is rounded and then stored.
Because you subtract very small values (probably), the value of the alarm never changes.

But even if alarms could contain decimals, you'd still run into trouble.

Just save yourself the hassle and create your own alarm system, it's not difficult at all.
 
Top