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

Legacy GM Hit-Stop Effect/Sleep Function Substitute [SOLVED]

A

Adventurous_Elf

Guest
UPDATE [25/09/2016]: Turns out the simplest solution to the following problem is to write a script function that compares the 'current_time' to a specified argument within a while loop. This way, the game is unable to process anything whilst the while loop is running, achieving the desired effect.
Thanks to everyone for your suggestions!


Hi there,

I was wondering what would be the most efficient way to create a 'Hit-Stop' effect within Game Maker: Studio.
By 'Hit-Stop', I mean the kind of effect where the entire game pauses for a couple of frames at a time, most commonly to accentuate the effect of an impact such as a punch or a gunshot. Perhaps the most famous example of this is within fighting games such as Street Fighter 2 (I included a clip below in case anyone is interested).


So far, I have tried solutions involving 'instance_deactivate_all', but this seems to turn objects involved translucent, which I guess means that function shows that deactivated objects aren't rendered for the duration.
It also doesn't stop the background layer from moving, as I'm currently accessing 'background_vspeed' to make it move downward.

Does anyone have any ideas?
 
Last edited by a moderator:
A

Adventurous_Elf

Guest
Have you tried setting room_speed? That will slow everything down.
Thank you for the suggestion, FrostyCat.
Yes, I have. That failed miserably.
The problem with messing around with the room speed is that the game performs logic steps slower in real time. What I mean by this is that when I try to set it to '1' (the lowest value where it won't crash) the game is now capped to 1fps, which is horrible. It means that I have to perform everything during the hitstop around 60 times slower as my game is configured for 60fps. What I'm really looking for is for everything in the game to stop what it is doing for say, 6 frames worth of animation, whilst the game is technically running normally in the background.

I could try working around an existing slow motion solution which ties every variable set to a 'DeltaTime' global value through multiplication, come to think of it. Once configured I could just set the delta time of everything to '0' for a while, possibly through an alarm. Though this seems quite a long form solution for someone who may not even want slow motion in their game.

I should probably find a link to where I found that solution, come to think of it.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Some GameMaker games implement this kind of effect simply as synchronous wait,
Code:
/// sleep_hack(time_in_ms)
var t = current_time + argument0;
while (current_time < t) { }
 
A

Adventurous_Elf

Guest
Some GameMaker games implement this kind of effect simply as synchronous wait,
Code:
/// sleep_hack(time_in_ms)
var t = current_time + argument0;
while (current_time < t) { }
Hey! This seemed to work pretty well. Argument0 is more sensitive than I expected, but it seems functional. Any major warnings I should receive before I start using this everywhere?
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Hey! This seemed to work pretty well. Argument0 is more sensitive than I expected, but it seems functional. Any major warnings I should receive before I start using this everywhere?
The game window becomes non-interactive while waiting this way, so make sure that the game can't "lock up" if there's too much going on (Nuclear Throne had this problem with explosions).
 
E

elementbound

Guest
If you don't do anything fancy with the drawing, you could also make a copy of the application surface, deactivate everything ( except your current object, ofc ), draw that surface for a few steps, then reactivate everything. I can write a quick example if you'd like to.

Otherwise, the sleep_hack solution is perfectly fine.
 
A

Adventurous_Elf

Guest
The game window becomes non-interactive while waiting this way, so make sure that the game can't "lock up" if there's too much going on (Nuclear Throne had this problem with explosions).
I will try to keep this in mind. Thank you!
 

Mr Errorz

Member
Some GameMaker games implement this kind of effect simply as synchronous wait,
Code:
/// sleep_hack(time_in_ms)
var t = current_time + argument0;
while (current_time < t) { }
So, if I put this in just one obj that'll work?
I mean, will It make the whole game "sleep" or just the obj running this code?
 

NightFrost

Member
So, if I put this in just one obj that'll work?
I mean, will It make the whole game "sleep" or just the obj running this code?
It locks up the program. Essentially that code means intentionally putting your game into an infinite loop state, except this loop has an escape clause.
 

TheouAegis

Member
I don't know why everyone keeps citing Street Fighter II. There is no hit-stop that affects the whole game. The clock is still counting down at normal speed. The only "stop" is the players and any projectiles. This is all handled with a global variable which simple is checked and then prevents any movement while the variable is set.
 

Mr Errorz

Member
I don't know why everyone keeps citing Street Fighter II. There is no hit-stop that affects the whole game. The clock is still counting down at normal speed. The only "stop" is the players and any projectiles. This is all handled with a global variable which simple is checked and then prevents any movement while the variable is set.
I think a full stop to everything can't be a good idea, I imagine it would be most noticeable on the audio of the game,
if the audio stopped for a fraction of a second every time there was a hit, it would be very annoying.
That's kinda why I asked if that script is per object or just once for the whole game.
 
Top