Specific frame input reading

S

Shaddy

Guest
Hi, I am a bit of a newbie,

I am creating a beat`Em Up game with the GMS2 and a mechanic I would like to implement is that if the player presses an attack button (or combination of attack buttons) in just the right frame, the player would do more damage and enable stronger combos... how would I be able to program this? I am aware of states and I know a bit about how the combo system should work, but I am not sure how to really do the frame perfect check...

I have not tried programming it yet, I like to plan before I program...

Thanks for the help!
 

JackTurbo

Member
So objects in gms have an image_number built-in variable that tracks the current frame the animation is on so you could use that. However this tracks the animation frames not the actual screen frames.

It's common to have 2d animations running at a lower frame rate than the game logic, 12 or 15fps are common. This means each animation frame is displayed for 5 or 4 screen frames if your game is 60fps.

So if you wanted to make your timing precise to a single frame you might want to approach it differently, perhaps using a counter or something (although this can get messy if you start mucking about with time for things like hitstop etc).
 
S

Shaddy

Guest
So objects in gms have an image_number built-in variable that tracks the current frame the animation is on so you could use that. However this tracks the animation frames not the actual screen frames.

It's common to have 2d animations running at a lower frame rate than the game logic, 12 or 15fps are common. This means each animation frame is displayed for 5 or 4 screen frames if your game is 60fps.

So if you wanted to make your timing precise to a single frame you might want to approach it differently, perhaps using a counter or something (although this can get messy if you start mucking about with time for things like hitstop etc).
that... sounds very dodgy, I might just make the moves harder to do ... suddenly I understand fighting games Dev slightly better...
 

JackTurbo

Member
It's pretty standard, not sure why you think it sounds shady. Most fighting games have their logic tied directly to the frame rate
 
N

NoFontNL

Guest
image_number gives you the number of subimages a sprite has.
You should use image_index instead.
 

Yal

šŸ§ *penguin noises*
GMC Elder
image_index also is a real, not an integer, so it has decimals... you can get the exact frame with frame = round(image_index/image_speed); (just don't do it when image_speed is 0 :p)
 
S

Shaddy

Guest
Thanks everyone... I decided to make a slightly easier game with shooting involved first, then I will use your guys advice for you next game!
 
Top