如何使用 WASD 或箭头键进行平滑旋转?我看到了一些例子,但他们都使用鼠标。我当然想使用 WASD 或箭头键。我真的希望有人可以帮助我。
到目前为止,这是我的代码。
// You can write your code in this editor
if(keyboard_check_pressed(ord("W"))) or (keyboard_check_pressed(vk_up)){
speed = sailSpeed;
image_speed = 1;
}
if(keyboard_check_released(ord("W"))) or (keyboard_check_released(vk_up)){
speed = 0;
image_speed = 0;
image_index = 0;
}
if(keyboard_check_pressed(ord("D"))) or keyboard_check_pressed(vk_right){
direction -= 45;
}
if(keyboard_check_pressed(ord("A"))) or keyboard_check_pressed(vk_left){
direction += 45;
}
if(direction == 0) or (direction == 360) or (direction == -360){
sprite_index = sprPlayerShipRight;
}
if(direction == 45) or (direction == -315){
sprite_index = sprPlayerShipUpRight;
}
if(direction == 90) or (direction == -270){
sprite_index = sprPlayerShipUp;
}
if(direction == 135) or (direction == -225){
sprite_index = sprPlayerShipUpLeft;
}
if(direction == 180) or (direction == -180){
sprite_index = sprPlayerShipLeft;
}
if(direction == 225) or (direction == -135){
sprite_index = sprPlayerShipDownLeft;
}
if(direction == 270) or (direction == -90){
sprite_index = sprPlayerShipDown;
}
if(direction == 315) or (direction == -45){
sprite_index = sprPlayerShipDownRight;
}