N
NURT
Guest
Please help me make the 8 direction control, I have arrow control, but I would like to make the control on W, S, A, D Here is the code:
Create:
spd = 3.0;
image_speed = .4;
Step:
//move
hInput = keyboard_check(vk_right) - keyboard_check(vk_left);
vInput = keyboard_check(vk_down) - keyboard_check(vk_up);
if(hInput !=0 or vInput !=0){
dir = point_direction(0,0,hInput,vInput);
moveX =lengthdir_x(spd, dir);
moveY =lengthdir_y(spd, dir);
x += moveX;
y += moveY;
//sprite
switch(dir){
case 0: sprite_index = spr_r_strip4; break;
case 45: sprite_index = spr_ur_strip4; break;
case 90: sprite_index = spr_u_strip4; break;
case 135: sprite_index = spr_ul_strip4; break;
case 180: sprite_index = spr_l_strip4; break;
case 225: sprite_index = spr_dl_strip4; break;
case 270: sprite_index = spr_d_strip4; break;
case 315: sprite_index = spr_dr_strip4; break;
}
} else {
image_index = 0;
}
Create:
spd = 3.0;
image_speed = .4;
Step:
//move
hInput = keyboard_check(vk_right) - keyboard_check(vk_left);
vInput = keyboard_check(vk_down) - keyboard_check(vk_up);
if(hInput !=0 or vInput !=0){
dir = point_direction(0,0,hInput,vInput);
moveX =lengthdir_x(spd, dir);
moveY =lengthdir_y(spd, dir);
x += moveX;
y += moveY;
//sprite
switch(dir){
case 0: sprite_index = spr_r_strip4; break;
case 45: sprite_index = spr_ur_strip4; break;
case 90: sprite_index = spr_u_strip4; break;
case 135: sprite_index = spr_ul_strip4; break;
case 180: sprite_index = spr_l_strip4; break;
case 225: sprite_index = spr_dl_strip4; break;
case 270: sprite_index = spr_d_strip4; break;
case 315: sprite_index = spr_dr_strip4; break;
}
} else {
image_index = 0;
}