M
Mustangfunnycar
Guest
Hello!
While working on my platformer game, I ran into a small snag while testing it. My level has several overhanging platforms where the character jumps up and onto. However, when my character goes directly underneath a platform a certain ways above, a blue line appears under the character, like a shadow, and the character cannot jump at all. If I jump before entering the "shadowed" area, I will be slightly floating above the floor objects, and will sink a pixel into the ground when I enter the "shadowed" area. Horizontal movement is not hindered when any of this is happening. Here is the source code:
In the Create Event:
///Initialize Variables
grav = 0.3;
hsp = 0;
vsp = 0;
jumpspeed = 7;
movespeed = 4;
In the Step Event:
///Player Input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);
//React to Inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;
if (place_meeting(x,y+1,obj_wall))
{
vsp = key_jump * -jumpspeed
}
//Horizontal Collsion
if (place_meeting(x+hsp,y,obj_wall))
{
while(!place_meeting(x+sign(hsp),y,obj_wall))
{
x += sign(hsp);
}
hsp = 0;
}
if (place_meeting(x+hsp,y,obj_rightwall))
{
while(!place_meeting(x+sign(hsp),y,obj_rightwall))
{
x += sign(hsp);
}
hsp = 0;
}
if (place_meeting(x+hsp,y,obj_leftwall))
{
while(!place_meeting(x+sign(hsp),y,obj_leftwall))
{
x += sign(hsp);
}
hsp = 0;
}
//Vertical Collision
if (place_meeting(x,y+vsp,obj_wall))
{
while(!place_meeting(x,y+sign(vsp),obj_wall))
{
y += sign(vsp);
}
vsp = 0;
}
if (place_meeting(x,y+vsp,obj_rightwall))
{
while(!place_meeting(x,y+sign(vsp),obj_rightwall))
{
y += sign(vsp);
}
vsp = 0;
}
if (place_meeting(x,y+vsp,obj_leftwall))
{
while(!place_meeting(x,y+sign(vsp),obj_leftwall))
{
y += sign(vsp);
}
vsp = 0;
}
//Quitting Function
if keyboard_check(vk_escape)
{
game_end();
}
y += vsp;
x += hsp;
Is there anything I should do to fix this problem?
If any more source code/pictures/video is required, I will be happy to supply.
Thanks in advance!
While working on my platformer game, I ran into a small snag while testing it. My level has several overhanging platforms where the character jumps up and onto. However, when my character goes directly underneath a platform a certain ways above, a blue line appears under the character, like a shadow, and the character cannot jump at all. If I jump before entering the "shadowed" area, I will be slightly floating above the floor objects, and will sink a pixel into the ground when I enter the "shadowed" area. Horizontal movement is not hindered when any of this is happening. Here is the source code:
In the Create Event:
///Initialize Variables
grav = 0.3;
hsp = 0;
vsp = 0;
jumpspeed = 7;
movespeed = 4;
In the Step Event:
///Player Input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);
//React to Inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;
if (place_meeting(x,y+1,obj_wall))
{
vsp = key_jump * -jumpspeed
}
//Horizontal Collsion
if (place_meeting(x+hsp,y,obj_wall))
{
while(!place_meeting(x+sign(hsp),y,obj_wall))
{
x += sign(hsp);
}
hsp = 0;
}
if (place_meeting(x+hsp,y,obj_rightwall))
{
while(!place_meeting(x+sign(hsp),y,obj_rightwall))
{
x += sign(hsp);
}
hsp = 0;
}
if (place_meeting(x+hsp,y,obj_leftwall))
{
while(!place_meeting(x+sign(hsp),y,obj_leftwall))
{
x += sign(hsp);
}
hsp = 0;
}
//Vertical Collision
if (place_meeting(x,y+vsp,obj_wall))
{
while(!place_meeting(x,y+sign(vsp),obj_wall))
{
y += sign(vsp);
}
vsp = 0;
}
if (place_meeting(x,y+vsp,obj_rightwall))
{
while(!place_meeting(x,y+sign(vsp),obj_rightwall))
{
y += sign(vsp);
}
vsp = 0;
}
if (place_meeting(x,y+vsp,obj_leftwall))
{
while(!place_meeting(x,y+sign(vsp),obj_leftwall))
{
y += sign(vsp);
}
vsp = 0;
}
//Quitting Function
if keyboard_check(vk_escape)
{
game_end();
}
y += vsp;
x += hsp;
Is there anything I should do to fix this problem?
If any more source code/pictures/video is required, I will be happy to supply.
Thanks in advance!
Last edited by a moderator: