• 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!

GML [SOLVED] What is the best way to speed up entire game and what should I be aware of?

MartinK12

Member
I'm making my tower defense project and now I want to speed up the game. But when I started to think about it, I realize that this might be more complicated :(

I want to speed up ie. 2x, 3x, 4x

Should I create some variable like game_speed and use it to calculate speed of each object, ie like
Code:
tower_reload_speed = 32 * game_speed;
And what about room_speed and path speed?
And what about animations?

And what about values? Should all values be equally divided by the same number ie 32 so when I speed up the game values don't screw up statistics of different objects?

Or maybe I should use the speed of 2x, 4x, 8x?

:)

I'm just looking for the best way to make sure that everything will use the same speed value and won't mess up anything. Maybe u know about some simple tutorial on this matter?

Thank You for all suggestions.
Martin - newbie ;)
 

sp202

Member
room_speed is the easy way to go, but hardly the best. Chances are a lot of devices won't be able to keep up with the framerate. The best thing to do is probably a game_speed factor. This is very similar to delta time which might be a good idea to look into.
 

Bingdom

Googledom
(Easy way)
I think room_speed would be a decent way to go (make sure you aren't doing things like alarm[0] = room_speed). You can't simply just speed up enemies. You also got to reduce a lot of timing. If you just speed up the enemies and reduced reload speeds, there's a chance you'll skip tower ranges and effect how the enemies are damaged.

(Possibly more difficult way but would have less draw calls = better performance)
If you can figure out how to repeat all of the object's step events and stuff multiple times in a frame (something like event_peform), then that would possibly require you to have custom alarms.

I'd probably go in the 1x 2x 3x range.

I haven't gotten into making gameplay dynamically change in speed, so these are just assumptions and probably wrong.
 
Z

zmads

Guest
Try to create a script that all objects get the speed based on it and call in the create event.
An example would be

In the script
spd = 1;

In the create events of the units
foot_soldier = spd + 4;
grunt_warrior = spd + 1;

In the step event of the units
tower_projectile = spd + 2;
mage_spell = spd + 5;

Then in the script you can create variables that can multiply the central speed by 2 or 3 or as much as you want without the need to change unit by unit every single time you want to adjust
But remember, the spd variable need a positive value as 0.5 or 1, if you try with 0 as simple as multiplication goes, you now that always will be 0, so no changes in the others values
If you need something that must have the variable but without speed just do
king = spd - 1;

And I think this should work, I never tried that, just trying to figuring it out to help :)
 

sp202

Member
@zmads All that relative speed stuff seems incredibly unnecessary. I think just a multiplier across all speeds/collision, etc will work just fine.
 
Z

zmads

Guest
@zmads All that relative speed stuff seems incredibly unnecessary. I think just a multiplier across all speeds/collision, etc will work just fine.
Since you said room_speed is not the right path, I was thinking in another way to make it easier to change the speed with the code he already have, just to adapt including a variable that control the speed of all the things in the game.
So it does not have to multiply the speed of each object separately and when he need to adjust, only need to change the value in the script without the need to change every single code.
 

sp202

Member
@zmads If you're adding a value onto speed after the multiplier then the ratio isn't preserved. Adding a value onto some centralized variable is a waste of time because you still have to spend time going through the code (erroneously) adding spd to every speed when it could be spent implementing the multiplier directly.
 
Z

zmads

Guest
@zmads If you're adding a value onto speed after the multiplier then the ratio isn't preserved. Adding a value onto some centralized variable is a waste of time because you still have to spend time going through the code (erroneously) adding spd to every speed when it could be spent implementing the multiplier directly.
If you don't mind, may you draft a brief example so that I can understand better?
 
Top