A
Adjud
Guest
Hi,
I attempted to get my character to move based on the up down left and right keys, while also changing the sprite to the direction of the key pressed based on variables, I have a variable "motion" telling the sprite weather to animate or not. here is the code, the sprite does not change nor does it move, im assuming "friction" isn't being used correctly.
I attempted to get my character to move based on the up down left and right keys, while also changing the sprite to the direction of the key pressed based on variables, I have a variable "motion" telling the sprite weather to animate or not. here is the code, the sprite does not change nor does it move, im assuming "friction" isn't being used correctly.
Code:
if (keyboard_check_pressed(vk_left)) {
friction=0;
motion=1
dir=2;
direction = 180;
speed=1;
}
else {
friction=1;
}
if (keyboard_check_pressed(vk_right)) {
friction=0;
motion=1
dir=1;
direction = 0;
speed=1;
}
else {
friction=1;
}
if (keyboard_check_pressed(vk_down)) {
friction=0;
motion=1
dir=0;
direction = 270;
speed=1;
}
else {
friction=1;
}
if (keyboard_check_pressed(vk_up)) {
friction=0;
motion=1
dir=3;
direction = 90;
speed=1;
}
else {
friction=1;
}
if dir = 0 {
if motion=1 {
image_index=sprstf;
image_speed=1;
}
else {
image_index=sprstf;
image_speed=0;
}
}
if dir = 1 {
if motion=1 {
image_index=sprstr;
image_speed=1;
}
else {
image_index=sprstr;
image_speed=0;
}
}
if dir = 2 {
if motion=1 {
image_index=sprstl;
image_speed=1;
}
else {
image_index=sprstl;
image_speed=0;
}
}
if dir = 3 {
if motion=1 {
image_index=sprstb;
image_speed=1;
}
else {
image_index=sprstb;
image_speed=0;
}
}