L
LWCreations
Guest
Hi, I'm an absolute beginner to Gamemaker coming from Fusion 2.5 and having some issues with movement that doesn't make sense in why it's not working, I'm using GML rather than the DnD interface as I want to move away from being limited to what I can do and need more freedom.
Currently, I'm trying to move my player in increments of 4 pixels when XRemaining is greater than 0 but instead of move 16 pixels as that is what I add the XRemaining it only moves 4 pixels.
I'll add the code below so it makes more sense, hopefully, someone can help me.
This code is in the STEP event.
I feel like this should work but it doesn't work as it should.
Currently, I'm trying to move my player in increments of 4 pixels when XRemaining is greater than 0 but instead of move 16 pixels as that is what I add the XRemaining it only moves 4 pixels.
I'll add the code below so it makes more sense, hopefully, someone can help me.
This code is in the STEP event.
Code:
XSpeedInc = 4;
YSpeedInc = 4;
XRemaining = 0;
YRemaining = 0;
//Directions are 1 = up, 2 = right, 3 = down, 4 = left
PlayerDirection = 0;
if keyboard_check(vk_left) && place_free (x-16,y) && XRemaining = 0
{
// x = (x - XSpeedInc);
XRemaining = 16;
PlayerDirection = 4;
}
if keyboard_check(vk_right) && place_free (x+16,y) && XRemaining = 0
{
// x = (x + XSpeedInc);
XRemaining = (16);
PlayerDirection = 2;
}
//Left Movement
if XRemaining > 0 && place_free (x-XSpeedInc,y) && PlayerDirection = 4
{
x = (x - XSpeedInc);
XRemaining = XRemaining - XSpeedInc
}
//Right Movement
if XRemaining > 0 && place_free (x+XSpeedInc,y) && PlayerDirection = 2
{
x = (x + XSpeedInc);
XRemaining = XRemaining - XSpeedInc
}