Windows bounce off wall after wall jump?

ellumnars

Member
1614547870988.png

Step event
GML:
///input

lkey = -(keyboard_check(ord("A")));
rkey = (keyboard_check(ord("D")));
ukey = (keyboard_check_pressed(vk_space));

move = lkey + rkey;
hspd = move * movespd;

///ground check

grounded = place_meeting(x,y+1, objsolid);


if (vsp < maxgrav) vsp += grav;
if grounded jumps = global.maxjumps;

if ukey && jumps > 0
{
    jumps -= 1;
    vsp = -jumpspd
}

///horizontal collision

if (place_meeting(x+hspd, y, objsolid)){
    while (!place_meeting(x+sign(hspd),y,objsolid)){
        x += sign(hspd);
    }
    clingable = true
    hspd = 0;
} else clingable = false
x += hspd;

///vertical collision

if (place_meeting(x, y+vsp, objsolid)) {
    while (!place_meeting(x,y+sign(vsp),objsolid)) {
        y += sign(vsp);
    }
    vsp = 0;
}


y += vsp;

    
///interaction with other objects
if place_meeting(x,y,Gravity1)
{
   vsp =- 2;
   jumps = global.maxjumps;
}

if place_meeting(x, y, objkill)
{
    room_restart()
    global.deathcount =+ 1
}

///wall clings
if grounded = false and clingable = true
{
    clinged = true
    grav = 0.2
} else
{
    grav = 0.4
    clinged = false
}

///wall jump

if ukey and clinged = true
{
    jumps -= 1;
    vsp = -jumpspd
}


///animations

if move != 0
{
    sprite_index = running
    image_xscale = move
} else sprite_index  = idle

if clinged = true
{
   sprite_index = clinging
}

if vsp != 0
{
   sprite_index = jumping
}
Create event
GML:
hspd = 0;
vsp = 0;
movespd = 4;
jumpspd = 5;
grav = 0.4;
maxgrav = 3;
global.maxjumps = 1
jumps = 1;
global.coincount = 0
room_speed = 60
clingable = false
clinged = false
global.deathcount = 0
paused = false
 
B

Ben Stitt

Guest
///wall jump
if ukey and clinged = true
{
jumps -= 1;
vsp = -jumpspd
}
So, you are clinging to the wall and then when jumping off want to go in the opposite direction I think. You can try setting horizontal speed to the opposite of whatever it currently is.
 

Mercyssh

Member
As the above poster mentions, I think you need to flip your horizontal speed around when jumping off a wall, and at the same time subtract a higher vsp so it goes "upwards"
 

woods

Member
in your step event..
Code:
.
.
if ukey and clinged = true
{
    jumps -= 1;
    vsp = -jumpspd
    hsp = -jumpspd //potential fix ;o)
}
 

NightFrost

Member
Well, one problem with your current code is how every step it resets hspd to (lkey + rkey) *movespd on line 8 so there's no way to carry horizontal velocity from step to step. Thus any push you might give from wall jumps will be overwritten the next step by your reading of controls. (Your vertical velocity does carry from step to step as you only set it on collisions.) This creates another problem: nothing tells you there was a wall jump on preceding steps, so you cannot adjust horizontal velocity for the fact.

So, to fix that, one way would be to create a variable that tells you there was a wall-clinging jump recently so hspd needs to be adjusted by certain amount. Then you have to decide how much this "recently" is - how long this push effect keeps adjusting hspd before it goes away. And make the adjust not bug out when player character hits another wall and starts clinging while the adjust still has some time left running. Further, you have to figure what to do with player controls while the push is acting on the character. Will you let player retain control, meaning walking into opposite direction will essentially cancel the jump push, or take control away, forcing the player to watch an uncontrollable jump?
 
Top