hyrule_3333
Member
Hello all,
I am brand new the the GameMaker community, as well as programming in general. I am trying to create a SNES era action RPG. I have been able to setup 4 directional only movement with the code below in my STEP event. I am trying to figure out how to make my character move a minimum of 16 pixels at a time. My character should move as normal as a direction is pushed, then animate and stop at the nearest 16 pixel increment. Currently my character moves one pixel at a time. I need code that when a direction is pressed, he will move in 16 pixel increments smoothly and stop. The character and all other tiles in my game are 32x32, which would mean 1/2 block movement per movement stop. Some other forums talked about the LERP function, but I cannot figure out how to put that into my code to correspond to movement and sprite transitions. I am using GameMaker Version 2.3.7.606. Any help would be greatly appreciated.
I am brand new the the GameMaker community, as well as programming in general. I am trying to create a SNES era action RPG. I have been able to setup 4 directional only movement with the code below in my STEP event. I am trying to figure out how to make my character move a minimum of 16 pixels at a time. My character should move as normal as a direction is pushed, then animate and stop at the nearest 16 pixel increment. Currently my character moves one pixel at a time. I need code that when a direction is pressed, he will move in 16 pixel increments smoothly and stop. The character and all other tiles in my game are 32x32, which would mean 1/2 block movement per movement stop. Some other forums talked about the LERP function, but I cannot figure out how to put that into my code to correspond to movement and sprite transitions. I am using GameMaker Version 2.3.7.606. Any help would be greatly appreciated.
GML:
switch (keyboard_key)
{
case vk_left:
case ord("A"):
x += walkSpeed;
image_speed = walkSpeed;
sprite_index = spr_Sumo_mvnt_L;
break;
case vk_right:
case ord("D"):
x += walkSpeed;
image_speed = walkSpeed;
sprite_index = spr_Sumo_mvnt_R;
break;
case vk_up:
case ord("W"):
y -= walkSpeed;
image_speed = walkSpeed;
sprite_index = spr_Sumo_mvnt_U;
break;
case vk_down :
case ord("S"):
y += walkSpeed;
image_speed = walkSpeed;
sprite_index = spr_Sumo_mvnt_D;
break;
default:
image_speed = 0;
image_index = 0;
walkSpeed = 1;
}