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

Stop sound option after two jumps

I have a double jump in place and currently, when you press the gamepad button, the jump sound plays along with the action. However, if you're still in the air and continue to press "jump", it keeps triggering the jump sound. I'm still a beginner, and I don't always understand how to write out the logic. Any suggestions?

GML:
if (gp_jump) {
    audio_play_sound(a_jump, 1, false);
    sprite_index = s_player_jump;
}

if (on_ground) {
    jumps = 0; // This will reset your jumps when you land and you will be able to double jump again
}

if (gp_jump and jumps <= jumps_max) { // You can jump until your "jumps" variable has reached your "jumps_max" variable
    if not on_ground { sprite_index = s_player_high_jump; }
    audio_play_sound(a_jump, 1, false);
    jumps += 2; //Adds to your jump
    y_speed = -jump_power;
}
 
Top