S
Sahibjot Cheema
Guest
Need help on this glitch. Everytime I jump and touch a wall and then press the opposite movement button to the wall, I get teleported to the wall on the other side and wise versa. Example, If I jump and touch the wall on the right and press left arrow key, I get teleported the very other wall on the left side and I can press right arrow key to move back to where i was.
Here is the code:
Here is the code:
//Horizontal Movement
hsp = 0;
maxhsp = 4;
maxhspInV = 2;
//Vertical Movement
vsp = 0;
vspMax = 5;
grv = 0.2;
//Jumping
jumpHeight = -5.6;
//Friction
groundFric = 1;
airFric = 4;
//Extra
onFloor = false;
time = 0;
hsp = 0;
maxhsp = 4;
maxhspInV = 2;
//Vertical Movement
vsp = 0;
vspMax = 5;
grv = 0.2;
//Jumping
jumpHeight = -5.6;
//Friction
groundFric = 1;
airFric = 4;
//Extra
onFloor = false;
time = 0;
//Air Friction
if (onFloor) var curFric = groundFric;
else var curFric = airFric;
//Player Controls
if (keyboard_check(vk_right)) hsp+=1 / curFric;
if (keyboard_check(vk_left)) hsp-=1 / curFric;
if (!keyboard_check(vk_left)) && (!keyboard_check(vk_right)) && (onFloor) hsp = 0;
key_jump = keyboard_check_pressed(ord("Z"));
key_jump_held = keyboard_check(ord("Z"));
hsp = clamp(hsp, -maxhsp, maxhsp);
vsp = Approach(vsp, vspMax, grv);
//Horizontal Collision
if (place_meeting(x+(hsp),y,oGrass))
{
while (!place_meeting(x+sign(hsp),y,oGrass))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+(vsp),oGrass))
{
while (!place_meeting(x,y+sign(vsp),oGrass))
{
y += sign(vsp);
}
vsp = 0;
onFloor = true;
}
y += vsp;
//Jump Mechanic
if (onFloor) && (key_jump)
{
vsp = jumpHeight;
onFloor = false;
grv = 0.2;
}
if (vsp < 0) && (!key_jump_held)
{
vsp = max(vsp,jumpHeight / 2);
}
//Animation
if (!onFloor)
{
if (hsp == 0)
{
if (sign(vsp) < 0)
{
time = 0;
sprite_index = Player_Still_Jump;
}
else
{
time = 0;
sprite_index = Player_Still_Fall;
grv = 0.25;
}
}
else
{
if (sign(vsp) < 0)
sprite_index = Player_Jump;
else
sprite_index = Player_Fall;
grv = 0.25;
}
}
else
{
if (hsp == 0)
{
time += 1;
if (time > 300)
{
sprite_index = Player_Idle;
}
}
else
{
time = 0;
sprite_index = Player_Walk;
}
}
if (hsp != 0)
{
image_xscale = sign(hsp);
}
time += 1;
if (time > 180)
{
}
if (onFloor) var curFric = groundFric;
else var curFric = airFric;
//Player Controls
if (keyboard_check(vk_right)) hsp+=1 / curFric;
if (keyboard_check(vk_left)) hsp-=1 / curFric;
if (!keyboard_check(vk_left)) && (!keyboard_check(vk_right)) && (onFloor) hsp = 0;
key_jump = keyboard_check_pressed(ord("Z"));
key_jump_held = keyboard_check(ord("Z"));
hsp = clamp(hsp, -maxhsp, maxhsp);
vsp = Approach(vsp, vspMax, grv);
//Horizontal Collision
if (place_meeting(x+(hsp),y,oGrass))
{
while (!place_meeting(x+sign(hsp),y,oGrass))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+(vsp),oGrass))
{
while (!place_meeting(x,y+sign(vsp),oGrass))
{
y += sign(vsp);
}
vsp = 0;
onFloor = true;
}
y += vsp;
//Jump Mechanic
if (onFloor) && (key_jump)
{
vsp = jumpHeight;
onFloor = false;
grv = 0.2;
}
if (vsp < 0) && (!key_jump_held)
{
vsp = max(vsp,jumpHeight / 2);
}
//Animation
if (!onFloor)
{
if (hsp == 0)
{
if (sign(vsp) < 0)
{
time = 0;
sprite_index = Player_Still_Jump;
}
else
{
time = 0;
sprite_index = Player_Still_Fall;
grv = 0.25;
}
}
else
{
if (sign(vsp) < 0)
sprite_index = Player_Jump;
else
sprite_index = Player_Fall;
grv = 0.25;
}
}
else
{
if (hsp == 0)
{
time += 1;
if (time > 300)
{
sprite_index = Player_Idle;
}
}
else
{
time = 0;
sprite_index = Player_Walk;
}
}
if (hsp != 0)
{
image_xscale = sign(hsp);
}
time += 1;
if (time > 180)
{
}