Im making a simple computerplayer to my simple 2d action game. it suppose to turn towards me and shoot, but i cant figure out how to calc the shortest path... should it turn left of right if it want to shoot and kill me :P ?
Ive got two angles: cpu_facing (direction the cpu is facing) and player_degree (the angle calculated when cpu is in the center).
(im working with degrees, dont like radian :P)
Anyone done this in javascript?
(cpu_facing-player_degree+360)%360>180
false
: turn in the negative directiontrue
: turn in the positive directionIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With