wrestitaway
Member
STEP EVENT
I've gotten the player to slide down on the right side with the correct sprite - but he doesn't seem to do it on the left side - and I don't know why. The code is in the horizontal collision using the temporary variable 'onawall' to check to see if he's on a wall. But it seems to only check the right side and I'm at a loss as to why.
If anyone can figure out my mistake (read poor coding) or help me figure out my next step, jumping from a wall slide, I would be greatly appreciative. Thanks.
GML:
//local var
var onawall = place_meeting(x+1,y,ob_wall) - place_meeting(x-1,y,ob_wall)
//Get the player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_down = -keyboard_check(vk_down);
key_jump = keyboard_check_pressed(vk_up);
/////////lives
if health
//React to inputs{
move = key_left + key_right ///NEW KEY CHECK!!!!!!!
xspd = move * movespeed;
dir=dir*move;
///animation
if move !=0 {image_xscale=move};
if place_meeting(x,y+1,ob_wall){movespeed=4;if move !=0
{sprite_index=sp_player} else sprite_index=sp_player_stand};
//////jumping
if (yspd < 10) yspd += grav;
if (place_meeting(x,y+1,ob_wall))
{ var jumps
jumps = true;
if (key_jump) yspd = -jumpspeed;
if (key_jump) and jumps {sprite_index=sp_player_jump} else jumps= false;
}
//Horizontal Collision
if (place_meeting(x+xspd,y,ob_wall))
{ if onawall {if yspd != 0 {sprite_index=sp_player_wall;yspd=0;jumps=true}; if keyboard_check_pressed(key_jump) and onawall {yspd+=1}}
while(!place_meeting(x+sign(xspd),y,ob_wall))
{
x += sign(xspd);
}
xspd = 0;
}
x += xspd;
//Vertical Collision
if (place_meeting(x,y+yspd,ob_wall))
{
while(!place_meeting(x,y+sign(yspd),ob_wall))
{
y += sign(yspd);
}
yspd = 0;
}
y += yspd;
///////////////hits///////////
if global.hit and alarm[2] <= 0 {
health -= 5;
alarm[2] = room_speed;
}
If anyone can figure out my mistake (read poor coding) or help me figure out my next step, jumping from a wall slide, I would be greatly appreciative. Thanks.