F
Freedom2Fight
Guest
Hello. I would like to request your help.
I am making a platformer. I am new to this but I am very eager to learn.
I want the playable character to able to "leap". So whenever I press the [jump button] the character will [jump and move forward] in the [direction they are facing] [a certain number of pixels]. Please see illustration below.
I call it "the absence of color leaping" - deep huh?
The code I provided below allows the player to jump and control their direction mid-air. Metal Slug was like that right? Good times. I, uh, don't want that... Its not the feel I'm looking for.
Here is the code and you might already have seen it in the tutorials:
Whenever I try to make adjustments things become super weird. For example as soon as the game starts, the player character gets yanked out of the room or whenever press space the player character moves forward and upward, forever - a double jump to eternity. Or they just slide forward.
How would you go about it?
Looking forward to your responses.
I am making a platformer. I am new to this but I am very eager to learn.
I want the playable character to able to "leap". So whenever I press the [jump button] the character will [jump and move forward] in the [direction they are facing] [a certain number of pixels]. Please see illustration below.
I call it "the absence of color leaping" - deep huh?
The code I provided below allows the player to jump and control their direction mid-air. Metal Slug was like that right? Good times. I, uh, don't want that... Its not the feel I'm looking for.
Here is the code and you might already have seen it in the tutorials:
Code:
key_right= keyboard_check(vk_right);
key_left= -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space) ;
move = key_left + key_right;
hsp = move*movespeed;
if (vsp < 10) vsp+=grav;
if (place_meeting(x,y+1,obj_wall1))
{
vsp = key_jump * -jumpspeed
}
x += hsp;
y += vsp;
//Horizontal Collision//
if (place_meeting(x+hsp,y,obj_wall1))
{ while (!place_meeting(x+sign(hsp),y,obj_wall1))
{x+= sign(hsp);}
hsp=0}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_wall1))
{ while (!place_meeting(x,y+sign(vsp),obj_wall1))
{y+= sign(vsp);}
vsp=0}
y += vsp;
//animation
if (move!=0)image_xscale = move;
if (place_meeting(x,y+1,obj_wall1))
{
if (hsp!=0) sprite_index = sprite3; else sprite_index = sprite_idle;
}
else
{
if (vsp<0) sprite_index = sprite_jump ; else sprite_index = sprite_fall
}
How would you go about it?
Looking forward to your responses.
Last edited by a moderator: