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
}
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