Kirbeh
Member
Ok so, I'm kind of new to coding and, obviously, tweaking and debugging.
So I've been following Shaun Spalding's tutorials. It seems they are pretty flawed for me though, but this far in I can't exactly switch to a new one.
So, his collision scripts were nowhere near loop-proof, so I managed to find a modification to change that.
But now I'm having a new issue. When my character walks, it glitches for a moment and gets stuck, and I have to jump to return to normal. When it walks into a wall, it glitches slightly into it.
Here's the code for more detail;
Idk where the error is, so help is greatly appreciated.
So I've been following Shaun Spalding's tutorials. It seems they are pretty flawed for me though, but this far in I can't exactly switch to a new one.
So, his collision scripts were nowhere near loop-proof, so I managed to find a modification to change that.
But now I'm having a new issue. When my character walks, it glitches for a moment and gets stuck, and I have to jump to return to normal. When it walks into a wall, it glitches slightly into it.
Here's the code for more detail;
GML:
///a (irrelevent here)
key_left = keyboard_check(ord("A"));
key_right = keyboard_check(ord("D"));
key_jump = keyboard_check_pressed(ord("W"));
///b
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp + grv;
if (place_meeting(x,y+1,oWall)) && (key_jump)
{
vsp = -9;
onthefloor = 1;
}
if (place_meeting(x + hsp, y, oWall)) {
repeat (abs(hsp) + 1) {
if (place_meeting(x + sign(hsp), y, oWall))
break;
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
if (place_meeting(x, y + vsp, oWall)) {
repeat (abs(vsp) + 1) {
if (place_meeting(x, y + sign(vsp), oWall))
break;
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
//animation
if (!place_meeting(x,y+1, oWall))
{
sprite_index = player3;
image_speed = 0;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
image_speed = 1;
if hsp == 0
{
sprite_index = player12;
}
else {
sprite_index = player;
}
}