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

Windows Help me with push up block and jump system (small reward who help me)

Hello my game current have fps,coin system,traps,checkpoint,life system,fade block,falling block and only two problem i have now.



My first problem is push ups block that i use from other engine to my new one.

End step script
GML:
// Actual collision checks + movement
var i;

// Vertical
for (i = 0; i < abs(v); ++i) {
    with (obj_Stick) {
        if (place_meeting(x, y + 1, other.id)) {
            if (!PlaceMeetingException(x, y + sign(other.v), obj_GroundCol, other.id))
                y += sign(other.v);
        }
        
        if (place_meeting(x, y - 1, other.id))
            y += sign(other.v);
    }

    if (!place_meeting(x, y + sign(v), obj_GroundCol))
        y += sign(v);
    else {
        v = 0;
        break;
    }
}

// Push stacks of blocks
with (oIce) {
    if (instance_place(x, y + 1, oIce))
       h = (instance_place(x, y + 1, oIce).h);
}

// Horizontal
for (i = 0; i < abs(h); ++i) {      // Move stacks
    // UP slope
    if (place_meeting(x + sign(h), y, obj_GroundCol) && !place_meeting(x + sign(h), y - 1, obj_GroundCol))
        --y;
    
    // DOWN slope
    if (!place_meeting(x + sign(h), y, obj_GroundCol) && !place_meeting(x + sign(h), y + 1, obj_GroundCol) && place_meeting(x + sign(h), y + 2, obj_GroundCol))
        ++y;       
        
    if (!place_meeting(x + sign(h), y, obj_GroundCol))
        x += sign(h);
    else {
        // Push other push blocks
        if (place_meeting(x + sign(h), y, oIce)) {
            with (instance_place(x + sign(h), y, oIce))
                if (instance_exists(obj_Stick))
                    h = obj_Stick.h
        } else
            h = 0;
        break;
    }
}

///////////////////////////////////////////////////////////////////////////////
Scripts
PlaceMeetingException
GML:
var exception = argument3;

with (argument2) {
    var callingObj = id;
    
    if (id == exception)
        continue;
    else
        with (other)
            if (place_meeting(argument0, argument1, callingObj))
            return true;
}

return false;
OnGround
GML:
/// OnGround();

return place_meeting(x, y + 1, obj_GroundCol);
Approach
GML:
/// Approach(start, end, shift);

if (argument0 < argument1)
    return min(argument0 + argument2, argument1);
else
    return max(argument0 - argument2, argument1);


Second problem is worst part about jumping


End Step jump code

GML:
// Launch player
if (place_meeting(x, y - 1, obj_Stick)) {
    // Shake screen
    with (oCamera) {
        alarm[0] = 10;
        screenShake = true;
    }

    // HIGH JUMP!
    with (obj_Stick)
        
      
    
    // Particles
    var i;
    for (i = 0; i < 8; ++i)
        with (instance_create(x + 8 + random_range(-8, 8), y, obj_Particle_Dust))
            direction = 90 + random_range(-45, 45);
}

// Launch push blocks (copy + paste)
if (place_meeting(x, y - 1, oIce)) {
    // Shake screen
    with (oCamera) {
        alarm[0] = 8;
        screenShake = true;
    }

    // HIGH JUMP!
    with (instance_place(x, y - 1, oIce)) { // Target specific push block
        v = -14;
        if (place_meeting(x, y - 1, obj_Stick)) {
            obj_Stick.y -= 14;
        }
    }
    
    // Particles
    var i;
    for (i = 0; i < 8; ++i)
        with (instance_create(x + 8 + random_range(-8, 8), y, obj_Particle_Dust))
            direction = 90 + random_range(-45, 45);
}



if place_meeting(x+hspeed,y,obj_Stick)
{
    hspeed = -hspeed;
}

//vertical
if place_meeting(x,y+vspeed,obj_Stick)
{
   vspeed = -vspeed;
}
This code give me error

// HIGH JUMP!
with (obj_Stick)
v = -jumpHeight * 2;

When i remove a v = jumpheight my player just shakescreen not jump automatic like on this video

GML:
############################################################################################
FATAL ERROR in
action number 1
of  Step Event2
for object oJump:

Variable obj_Stick.jumpHeight(100019, -2147483648) not set before reading it.
 at gml_Object_oJump_StepEndEvent_1 (line 11) -          v = -jumpHeight * 2;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_oJump_StepEndEvent_1 (line 11)
 

Attachments

Okay... where are you setting obj_Stick.jumpHeight? You haven't shown that part. I suspect that's because it doesn't exist.
I have this in obj_stick_control
GML:
///All things Jumping

// if the Jump Key has been pressed, the player can jump, and the players collision box is
//NOT colliding with the GroundCol above it...
if(keyJump && canJump && !place_meeting(x,y-2,obj_GroundCol))
{
    switch(state)
    {
        case "StandRight":
        case "RunRight":
        state = "JumpRight"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canJump = false; // player has jumped, therefore CANNOT jump again
        scr_CreateDust("NorthWest",2,x-10,y); // create "Dust" under the player
        scr_CreateDust("North",2,x,y); // create "Dust" under the player
        scr_CreateDust("NorthEast",2,x+10,y); // create "Dust" under the player
        // PLEASE NOTE: Arguments for ^ script -
        // argument0: direction
        // argument1: number of "dust particles" to create
        // argument2: x position
        // argument3: y position
        break;
        
        case "StandLeft":
        case "RunLeft":
        state = "JumpLeft"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canJump = false; // player has jumped, therefore CANNOT jump again
        scr_CreateDust("NorthWest",2,x-10,y); // create "Dust" under the player
        scr_CreateDust("North",2,x,y); // create "Dust" under the player
        scr_CreateDust("NorthEast",2,x+10,y); // create "Dust" under the player
        break;
        
        case "StandAimRight":
        case "RunAimRight":
        state = "JumpAimRight"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canJump = false; // player has jumped, therefore CANNOT jump again
        scr_CreateDust("NorthWest",2,x-10,y); // create "Dust" under the player
        scr_CreateDust("North",2,x,y); // create "Dust" under the player
        scr_CreateDust("NorthEast",2,x+10,y); // create "Dust" under the player
        break;
        
        case "StandAimLeft":
        case "RunAimLeft":
        state = "JumpAimLeft"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canJump = false; // player has jumped, therefore CANNOT jump again
        scr_CreateDust("NorthWest",2,x-10,y); // create "Dust" under the player
        scr_CreateDust("North",2,x,y); // create "Dust" under the player
        scr_CreateDust("NorthEast",2,x+10,y); // create "Dust" under the player
        break;
        
        case "JumpRight":
        case "FallRight":
        state = "JumpRight"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canJump = false; // player has jumped, therefore CANNOT jump again
        break;
        
        case "JumpLeft":
        case "FallLeft":
        state = "JumpLeft"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canJump = false; // player has jumped, therefore CANNOT jump again
        break;
        
        case "JumpAimRight":
        case "FallAimRight":
        state = "JumpAimRight"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canJump = false; // player has jumped, therefore CANNOT jump again
        break;
        
        case "JumpAimLeft":
        case "FallAimLeft":
        state = "JumpAimLeft"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canJump = false; // player has jumped, therefore CANNOT jump again
        break;
        
        case "WallslideRight":
        state = "WallJumpLeft"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canJump = false; // player has jumped, therefore CANNOT jump again
        canDoubleJump = false; // set to true if you wish for the player to be able to double jump from a wall jump
        scr_CreateDust("NorthWest",3,x+16,y); // create "Dust" under the player
        scr_CreateDust("North",3,x+16,y); // create "Dust" under the player
        break;
        
        case "WallslideLeft":
        state = "WallJumpRight"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canJump = false; // player has jumped, therefore CANNOT jump again
        canDoubleJump = false; // set to true if you wish for the player to be able to double jump from a wall jump
        scr_CreateDust("North",3,x-16,y); // create "Dust" under the player
        scr_CreateDust("NorthEast",3,x-16,y); // create "Dust" under the player
        break;
        
        case "WallslideAimRight":
        state = "WallJumpAimLeft"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canJump = false; // player has jumped, therefore CANNOT jump again
        canDoubleJump = false; // set to true if you wish for the player to be able to double jump from a wall jump
        scr_CreateDust("NorthWest",3,x+16,y); // create "Dust" under the player
        scr_CreateDust("North",3,x+16,y); // create "Dust" under the player
        break;
        
        case "WallslideAimLeft":
        state = "WallJumpAimRight"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canJump = false; // player has jumped, therefore CANNOT jump again
        canDoubleJump = false; // set to true if you wish for the player to be able to double jump from a wall jump
        scr_CreateDust("North",3,x-16,y); // create "Dust" under the player
        scr_CreateDust("NorthEast",3,x-16,y); // create "Dust" under the player
        break;
    }
}

else

//BONUS:

/*
if the player has unlocked the ability to "Double Jump"
*/

if(keyJump && canDoubleJump && doubleJumpUnlocked)
{
    switch(state)
    {
        case "JumpRight":
        case "FallRight":
        state = "JumpRight"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canDoubleJump = false; // has double jumped/cannot jump again
        break;
        
        case "JumpLeft":
        case "FallLeft":
        state = "JumpLeft"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canDoubleJump = false; // has double jumped/cannot jump again
        break;
        
        case "JumpAimRight":
        case "FallAimRight":
        state = "JumpAimRight"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canDoubleJump = false; // has double jumped/cannot jump again
        break;
        
        case "JumpAimLeft":
        case "FallAimLeft":
        state = "JumpAimLeft"; // set state to jumping
        ySpeed = -jumpHeight; // set players yvelocity to the jumpHeight var
        canDoubleJump = false; // has double jumped/cannot jump again
        break;
    }
}

// Controlled Jump

if(keyJumpReleased) // if the player releases the Jump Key
{
    if(ySpeed < 0) ySpeed = 0; // If the players yvelocity is moving in the "Up" direction, stop his momentum
}

// Force player to "Move" left or right while in the "Wall Jump" state

if(state == "WallJumpRight" || state == "WallJumpAimRight")
{
    if(place_meeting(x+moveSpeed,y,obj_GroundCol)) // if player is colliding with the wall...
    {
        while(!place_meeting(x+sign(moveSpeed),y,obj_GroundCol)) // but the player is NOT one pixel away...
        {
            x += sign(moveSpeed); // move player one pixel towards the wall until colliding with it
        }
    }
    
    if(!place_meeting(x+moveSpeed,y,obj_GroundCol)) // if the player is NOT colliding with the wall...
    {
        x += moveSpeed; // move player until collision occurs
    }
}

if(state == "WallJumpLeft" || state == "WallJumpAimLeft")
{
    if(place_meeting(x-moveSpeed,y,obj_GroundCol)) // if player is colliding with the wall...
    {
        while(!place_meeting(x-sign(moveSpeed),y,obj_GroundCol)) // but the player is NOT one pixel away...
        {
            x -= sign(moveSpeed); // move player one pixel towards the wall until colliding with it
        }
    }
    
    if(!place_meeting(x-moveSpeed,y,obj_GroundCol)) // if the player is NOT colliding with the wall...
    {
        x -= moveSpeed; // move player until collision occurs
    }
}

// if the player has jump 1/3 of his jumpHeight, allow player to take control again
if(ySpeed > -jumpHeight + jumpHeight/3) // yvelocity is 1/3 players jumpHeight
{
    switch(state)
    {
        case "WallJumpRight":
        state = "JumpRight"; // set state to jumping
        break;
        
        case "WallJumpLeft":
        state = "JumpLeft"; // set state to jumping
        break;
        
        case "WallJumpAimRight":
        state = "JumpAimRight"; // set state to jumping
        break;
        
        case "WallJumpAimLeft":
        state = "JumpAimLeft"; // set state to jumping
        break;
    }
}
 
Okay, but you didn't answer the question.



Show the assignment of a value TO jumpHeight. You have not shown this. You must show this.
Hm i cant find this part i have only this up and this code in my obj player
GML:
///Initialize Variables

globalvar state; // the players state
state = "StandRight"; // set the players initial state
globalvar showDebug; // debug overlay
showDebug = false; // do not show on startup
globalvar paused; // pausing the game
paused = false; // the game is not paused


moveSpeed = 10; // players move speed
ySpeed = 0; // players yvelocity speed
grav = 1.2; // players gravity
wallGrav = 1.5; // gravity while on wall(used for wallslide)
jumpHeight = 16; // height the player will jump
fireRate = 30; // rate of fire(lower = faster)
bulletSpeed = 40; // speed of bullet

canJump = true; // can the player jump?
canDoubleJump = true; // can the player double jump?
canFire = true; // can the player fire?
isFiring = false; // is the player currently firing?
 
This part is working
GML:
if (place_meeting(x, y - 1, oIce)) {
    // Shake screen
    with (oCamera) {
        alarm[0] = 8;
        screenShake = true;
    }

    // HIGH JUMP!
    with (instance_place(x, y - 1, oIce)) { // Target specific push block
        v = -14;
 

Nidoking

Member
Hm i cant find this part
I suspect that's because it doesn't exist.
You have to tell the program what value you want the variable to have, if you want to use the value that the variable has. You need to assign a value to the variable. If you have never done this, then it has not been done. It needs to be done. You need to assign a value to the variable before you use it.

I see that you're assigning a value to jumpHeight in the obj_player. The obj_Stick doesn't know about that, because it is an obj_Stick and not an obj_player. If you want obj_Stick to use the jumpHeight in obj_player, then you need to tell it to do that. If you want obj_Stick to have its own jumpHeight, then you need to set it. You must do one or the other of these things.
 
Top