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

GameMaker Jumping cause a bump

K

Kyle Rider

Guest
Here is my jump code. Barely making the jump cause the player to glitch up about 32 pixels but otherwise my y collision is fine. This only changed when I made the jump from 30fps to 60 fps.

Making the game 60 fps solved a lot of problems with fast collision so I would rather not revert.

Code:
if( grav<0 )
{
    sprite_index = spr_vjump;
} else {                                    // otherwise, falling so check UNDER the player
    if(jump){                                // if coming down after jumping display the correct sprite
        sprite_index = spr_vfall;
    } else if(fall){                        // if falling from an edge display the fall sprite
        sprite_index = spr_vfall;
        jumps++;   
    } else {                                // if not already falling or jumping
        grav = 0;                            // first stop falling (used for ladders)
        fall = true;                        // flag that we are falling
    }
    // check the points at the bottom of the player character
    c1 = tilemap_get_at_pixel(obj_Game.map,x-12,y+1);    // left_bottom
    c2 = tilemap_get_at_pixel(obj_Game.map,x+12,y+1);    // right_bottom
    c3 = tilemap_get_at_pixel(obj_Game.map,x,y-1);// center for ladders!
    c4 = tilemap_get_at_pixel(obj_Game.map,x,y+1);    //CHECK FOR LADDER BELOW

    if( c1>=1 || c2>=1)
    {            // if they are intersecting with a tile
        if((c1 == 1) || (c2 == 1) || (c1 == 2) || (c2 == 2) || (c1 == 4) || (c3 == 4))
        {
            y = real(y&$FFFFFFE0);            // move the sprite to the top of the tile
            sprite_index = choose(spr_vidle);    // set the sprite to the idle sprite
            climbing = false;                // stop any climbing
            jump = false;                    // stop any jumping
            fall = false;                    // stop any falling
            jumps = 0;
        }
        if((c3 == 3) || (c4 == 4))
        {            // if we are intersecting with a ladder
            can_climb = true;
            if(c4 == 4){
            if (key_down != 0)
            {
                y = y + 1;
                state = states.ladder;
            }
        }
        if(c3 == 3){                            // if we are intersecting with a ladder
            can_climb = true;   
            if (key_up != 0)   
            {
                state = states.ladder;
            }       
        }                // flag that we can climb
        }
    } else {                                // if we are not intersecting any tiles
        climbing = false;                    // flag that we cannot climb
    }
}
 
Top