mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-10-31 20:09:53 +00:00
changed robot acceleration calc to use Java Math/copySign function
This commit is contained in:
parent
0945151aab
commit
cc1dee5418
@ -25,8 +25,8 @@
|
|||||||
"takes a robot and returns it, moved through space.
|
"takes a robot and returns it, moved through space.
|
||||||
helper function for tick-robot."
|
helper function for tick-robot."
|
||||||
[{:keys [pos-x pos-y v-x v-y desired-v-x desired-v-y] :as robot}]
|
[{:keys [pos-x pos-y v-x v-y desired-v-x desired-v-y] :as robot}]
|
||||||
(let [max-accel-x (if (neg? desired-v-x) (- MAX-ACCEL) MAX-ACCEL)
|
(let [max-accel-x (Math/copySign MAX-ACCEL desired-v-x)
|
||||||
max-accel-y (if (neg? desired-v-y) (- MAX-ACCEL) MAX-ACCEL)
|
max-accel-y (Math/copySign MAX-ACCEL desired-v-y)
|
||||||
{new-pos-x :d, new-v-x :v} (physics/d-and-v-given-desired-v
|
{new-pos-x :d, new-v-x :v} (physics/d-and-v-given-desired-v
|
||||||
pos-x
|
pos-x
|
||||||
v-x
|
v-x
|
||||||
|
Loading…
Reference in New Issue
Block a user