GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2020-08-28 14:14:08

redeyesmaster
Member
Registered: 2020-08-09
Posts: 43

lag() - A delta_time optimization.

I made this code for myself, honestly the code could be made by pretty much anyone, but the reason I'm posting it is because the ability to shrink your code a bit, and have optimized code really helps.

For those of you that didn't know multiplying takes less cpu then dividing, it's not that important but it's something to keep in mind for large projects.

Also, personally I named the code dt() since it's easier and faster to type on a qwarty keyboard, but just named it lag for memory sake.

Expand/// lag();
//
//  this function is simply the most optimal way to calculate lag
//  since computers multiply with fewer cpu instructions than they can divide
//
//  Returns: real
//
//  The returned is a multiplier value for lost frames,
//    this function is really only to server as a
//    replacement for dividing by delta_time by ideal_delta.
//
//  The function also helps clean up the code a bit in my opinion
//
/// GMLscripts.com/license


//returning this multiple allows for simple equasions like:   speed * lag()
return delta_time * room_speed * 0.000001

Offline

Board footer

Powered by FluxBB