r/gamemaker • u/clanmckay • 11d ago
Help! help on gm2
i have been trying to make a platformer type game and i watched a tutorial on how to move the character and grav etc but it does not work at all, copied everything correctly and there is no comments on the post just wondering if anyone can help
#region movement
//key input
var _key_left = keyboard_check(vk_left);
var _key_right = keyboard_check(vk_right);
var _key_jump = keyboard_check(vk_space);
//calculate movement
var _move = _key_right - _key_left;
h_speed = _move * move_sp;
v_speed += grav;
//moving the player
if (_key_left){
}
//jumping
if place_meeting(x, y+1, Obj_wall){
jumps = jump_max;
}
if (jumps > 0) && (_key_jump){
jumps -= 1;
v_speed = jump_height;
}
#endregion
#region collision: horizontal, vertical
//horizontal
if (place_meeting(x + h_speed, y, Obj_wall)){
while (!place_meeting(x + sign(h_speed), y, Obj_wall)){
x += sign(h_speed)
}
h_speed = 0;
}
x += h_speed;
//vertical
if (place_meeting(x, y + v_speed, Obj_wall)){
while (!place_meeting(x , y + sign(h_speed), Obj_wall)){
y += sign(v_speed)
}
v_speed = 0;
}
y += v_speed;
#endregion
0
Upvotes
1
u/germxxx 11d ago
"it does not work at all" Doesn't really help us narrow it down in any capacity.
You need to explain in detail what you've done and exactly what is happening, and what you expect to happen.
1
u/AmnesiA_sc 11d ago
If nothing at all is working, maybe it's not in the Step event or the object isn't in the room?