N
NickCikovic
Guest
I was testing my platform game to check for bugs and glitches in preparation for the real graphics when I encountered a very problematic glitch. If the player or an enemy touches a wall vertically AT ALL after dying, the game locks up so hard even pressing R doesn't reset it. I was following a tutorial on YouTube, confident I did everything exactly as the guy did, but it didn't help even after I looked through for probably 4 hours. I tried messing with the collision masks and points of origin of both the player/enemy and the wall itself, but that didn't work either. I need serious advice if this game is ever gonna make it to the market. The game can't freeze like that every time a dead character touches a wall. The following picture shows exactly what's going on. I can't even imagine why it's happening, but I THINK there may be an error in the Step Event code. It reads as follows. Any help is good. Thanks.
Code:
//Get Player Input
key_left = keyboard_check(vk_left) || keyboard_check(ord("A"));
key_right = keyboard_check(vk_right) || keyboard_check(ord("D"));
key_jump = keyboard_check_pressed(vk_space);
//Calculate Movement
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp + grv;
canjump -=1;
if (canjump > 0) && (key_jump)
{
vsp = -12;
canjump = 0;
}
//Horizontal Collision
if (place_meeting(x+hsp,y,oWall))
{
while (!place_meeting(x+sign(hsp),y,oWall))
{
x = x sign (hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,oWall))
{
while (!place_meeting(x,y+vsp,oWall))
{
y = y sign (vsp);
}
vsp = 0;
}
y = y + vsp;
//Animation
if (!place_meeting(x,y+1,oWall))
{
sprite_index = Player;
image_speed = 0;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
canjump = 10;
if (sprite_index == Player) audio_play_sound(snLanding,4,false);
image_speed = 1;
if (hsp == 0)
{
sprite_index = Player3;
}
else
{
sprite_index = Player2;
}
}
if (hsp != 0) image_xscale = sign(hsp);