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

[SOLVED] Top down jumping not working

K

kaerpaenen

Guest
Hello! I am very new to Game Maker, at least the coding part of it, and I have a problem with my jumping animation.

The game is like old school game boy zelda games, top down, 8 directions. I have made a 15 frame animation for jumping, and whenever space is pressed, it changes jumping state to 1, and supposedly when the animation ends, it sets it back to 0. It works perfectly - as long as I'm not moving. When moving it sorta works, sorta doesn't. It works every now and then, but usually it skips frames from the jumping animation beginning and rarely it even leaves the jumping animation looping.


Code:
//Jumping check
if (keyboard_check_pressed(vk_space) && jumping = 0)
    {
    jumping = 1;
    }

if ((image_index >= 14) && jumping = 1)
    {
    jumping = 0;
    }

if jumping = 1
    {
    image_speed = 1;
    sprite_index = spr_slime_jump;
    }
all my moving animations are specified like following:
Code:
if (swimming = 0 && jumping = 0)
{
    image_speed = 1;
  
    if (memory_direction = 0)
        {
        sprite_index = spr_slime_walk_right;
        }
etc.

The main problem is that it does work occasionally, but is very unreliable, maybe because of the "image_index >14"?
 

Simon Gust

Member
reset the image_index when you set jumping to 1.
Code:
if (keyboard_check_pressed(vk_space) && jumping = 0)
   {
   jumping = 1;
   image_index = 0;
   }
 
K

kaerpaenen

Guest
reset the image_index when you set jumping to 1.
Code:
if (keyboard_check_pressed(vk_space) && jumping = 0)
   {
   jumping = 1;
   image_index = 0;
   }
Ahh of course! Thank you, works like a charm now, you saved me a lot of headache!
 
Top