SOLVED get Angle based on keys

Hi all,

Like the title suggests.. is it possible to get an angle based on direction keys?

for instance if I press vk_right and vk_up it should give 45 degrees.

Simon Gust

you can do that by first calculating opposites of keys (right vs left, down vs up)
var horizontal_input = keyboard_check(vk_right) - keyboard_check(vk_left);
var vertical_input = keyboard_check(vk_down) - keyboard_check(vk_up);
Now horizontal gives you:
for only right: 1
for only left: -1
for both left and right: 0

and same for vertical inputs.

with these you can now put them into a single variable.
var input_direction = point_direction(0, horizontal_input, 0, vertical_input);
This function calculates the direction between 2 points. You offset these points from 0 to 1 or -1 depending on which button you press.