3
\$\begingroup\$

I currently have an orbital simulator, with a brilliant answer in another Game Development question here, and would like to know how to slow down the calculations of Game Maker, to be able to do more precise ones as my orbits suffer variably intense Apsidal Precession.

Examples of this can be found in games such as Kerbal Space Program and
Universe Sandbox 1/2. In KSP, you have the Max Physics Delta Time which allows slower gameplay, but more calculations. In Universe Sandbox you are able to change the accuracy of calculations causing orbits to go crazy and extremely precise.

How am I able to implement such a thing into GameMaker: Studio?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

You can implement a global variable that flips between each mode.

You can reduce the amount of frames that are being rendered per second.

So for example, for a manager object you can have this code in the create event:

//Slow mode
if(global.gameplayMode == 0)
{
    room_speed = 30;
}
//Fast mode
else if(global.gameplayMode == 1)
{
   room_speed = 60;
}

And for calculations

some_stuff = irandom(9001);
if(global.gameplayMode == 0)
{
   moreCalculations();
}

EDIT

//Declare the variable
global.worldPace;

//If you'd like the game to run at half speed then set it to 0.5
global.worldPace = 0.5;

//But if you'd like the game to run at regular speed then just set this to 1
global.worldPace = 1;

And for all of the calculations, just multiply everything by this variable so for example

runningSpeed = 9.8 * global.worldPace;

I've never fiddled with this idea but this is where I'd start. I'd consider the amount you have to add for geometric functions. You'll have to make sure that whatever value you add, you distribute in the exact same manner when slowed down.

A good example and simple example would be as follows:

If over one frame you move a bullet 2 pixels to the left, with this slow-mo mode you'd now have to split this simple action into two, which means that the action of bullet moving would span over two frames, and in each frame the bullet would only move 1 pixel.

I'd imagine this would be harder to nail down with more complicated functions, so be careful with how you approach them.

\$\endgroup\$
4
  • \$\begingroup\$ I don't think you understand, I'm looking to slow down the calculations ONLY, not the room_speed which is my framerate. \$\endgroup\$
    – user59493
    Commented Oct 16, 2015 at 6:21
  • \$\begingroup\$ @FinnRayment What does "slowing down the calculations" mean? By slowing the FPS down, you're giving the machine more time to work on calculations than rendering things on screen which in theory would be slower but more accruate like you asked. Unless you're talking about the game running in a slow-mo mode...? \$\endgroup\$
    – Omrii
    Commented Oct 16, 2015 at 8:26
  • \$\begingroup\$ Yes! The latter. Slow motion mode, where your FPS is constant, but game is slowed down for calculation time. \$\endgroup\$
    – user59493
    Commented Oct 17, 2015 at 10:11
  • \$\begingroup\$ @FinnRayment I'd just make on global variable that determines the time and multiple it by all of the calculations/variables in the game. I've edited my post above to express what I mean. \$\endgroup\$
    – Omrii
    Commented Oct 18, 2015 at 12:28

You must log in to answer this question.