DTheChemist
Member
Ok heres my first error code issue after following a Yoyo games youtube video tutorial.
my character becomes distorted in scale when i start to walk or shakes in animation error when i land from a jump. whats wrong with the code? Im still fresh at this engine
short video example here
GML:
/// @desc Core Player Logic
//Get Player Inputs
key_left= keyboard_check(vk_left);
key_right = keyboard_check(vk_right);
//key_down = keyboard_check(vk_down);
key_jump = keyboard_check_pressed(vk_space);
//Calculate movement
var _move = key_right - key_left;
hsp = _move * walksp;
//x = x + hsp;
vsp = vsp + grv;//vertical speed
//x = x + hsp;
//y = y + vsp;
if (place_meeting(x,y+1,oWall)) && (key_jump)
{
vsp = -jumpsp
}
//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+sign(vsp),oWall))
{
y = y + sign(vsp);
}
vsp =0;
}
y = y + vsp;
//Animation
if (!place_meeting(x,y+1,oWall))
{
sprite_index = jPlayer;
image_speed = 0;
if (vsp > 0) image_index = 1; else image_index = 0;///the frames of jump
}
else
{
image_speed = 1;
if (hsp == 0)
{
sprite_index = sPlayer;///the idle animation sprites
}
else
{
sprite_index = wPlayer;///the walk animation sprites
}
}
if (hsp != 0) image_xscale = sign(hsp);///flips sprite left or right
my character becomes distorted in scale when i start to walk or shakes in animation error when i land from a jump. whats wrong with the code? Im still fresh at this engine
short video example here
Last edited: