Specific frame input reading

Discussion in 'Programming' started by Shaddy, Jun 25, 2019.

  1. Shaddy

    Shaddy Member

    Joined:
    Jun 25, 2019
    Posts:
    19
    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!
     
  2. JackTurbo

    JackTurbo Member

    Joined:
    Oct 19, 2016
    Posts:
    824
    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).
     
  3. Shaddy

    Shaddy Member

    Joined:
    Jun 25, 2019
    Posts:
    19
    that... sounds very dodgy, I might just make the moves harder to do ... suddenly I understand fighting games Dev slightly better...
     
  4. JackTurbo

    JackTurbo Member

    Joined:
    Oct 19, 2016
    Posts:
    824
    It's pretty standard, not sure why you think it sounds shady. Most fighting games have their logic tied directly to the frame rate
     
  5. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    287
    image_number gives you the number of subimages a sprite has.
    You should use image_index instead.
     
  6. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,680
    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)
     
  7. Shaddy

    Shaddy Member

    Joined:
    Jun 25, 2019
    Posts:
    19
    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!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice