S
supermasher/ti
Guest
is there any way i can optimize this movement code to save space
OBJ_Player
Crate//:
Step//:
here is a video of what I have right now
https://photos.app.goo.gl/8tfhcUpk4cZaizSZ8
and i want it to look like what i have in the video
OBJ_Player
Crate//:
Code:
idle = 1;
walking = 0;
up = 3;
right = 2;
down = 1;
left = 0;
Action = idle;
Direction = down;
View[1,3] = v_p_upIdle;
View[1,2] = v_p_rightIdle;
View[1,1] = v_p_downIdle;
View[1,0] = v_p_leftIdle;
View[0,3] = v_p_upWalking;
View[0,2] = v_p_rightWalking;
View[0,1] = v_p_downWalking;
View[0,0] = v_p_leftWalking;
Code:
/// @description
if (keyboard_check(vk_up) || keyboard_check(vk_right) || keyboard_check(vk_down) || keyboard_check(vk_left)) {
Action = walking;
if (keyboard_check(vk_up)) {Direction = up;}
if (keyboard_check(vk_right)) {Direction = right;}
if (keyboard_check(vk_down)) {Direction = down;}
if (keyboard_check(vk_left)) {Direction = left;}
} else {Action = idle}
sprite_index = View[Action, Direction];
speed = 0; //this doesn't work if you have acceleration, but you don't have acceleration probably
if (keyboard_check(vk_up) || keyboard_check(vk_right) || keyboard_check(vk_down) || keyboard_check(vk_left)) {
Action = walking;
if (keyboard_check(vk_up)) {Direction = up; vspeed = -2;}
if (keyboard_check(vk_right)) {Direction = right; hspeed = 2;}
if (keyboard_check(vk_down)) {Direction = down; vspeed = 2;}
if (keyboard_check(vk_left)) {Direction = left; hspeed = -2;}
} else {Action = idle;}
https://photos.app.goo.gl/8tfhcUpk4cZaizSZ8
and i want it to look like what i have in the video