mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-05-28 23:41:31 +00:00
trying to fix shells
This commit is contained in:
parent
fe9294bff1
commit
37625c312b
|
@ -123,7 +123,8 @@
|
||||||
GAME-SECONDS-PER-SHOT)]
|
GAME-SECONDS-PER-SHOT)]
|
||||||
(assoc
|
(assoc
|
||||||
world-with-new-shot-timer
|
world-with-new-shot-timer
|
||||||
:shells (merge shells (shell/init-shell pos-x pos-y aim next-shell-id data))
|
:shells (merge shells {next-shell-id
|
||||||
|
(shell/init-shell pos-x pos-y aim data)})
|
||||||
:next-shell-id (inc next-shell-id))))))})
|
:next-shell-id (inc next-shell-id))))))})
|
||||||
|
|
||||||
(defn get-target-register
|
(defn get-target-register
|
||||||
|
|
|
@ -3,12 +3,11 @@
|
||||||
(:require [robotwar.physics :as physics]))
|
(:require [robotwar.physics :as physics]))
|
||||||
|
|
||||||
(defn init-shell
|
(defn init-shell
|
||||||
[pos-x pos-y aim id distance]
|
[pos-x pos-y aim distance]
|
||||||
; TODO: make the starting point dependent upon the robot radius,
|
; TODO: make the starting point dependent upon the robot radius,
|
||||||
; which should be in constants.
|
; which should be in constants.
|
||||||
(let [{unit-x :x unit-y :y} (physics/decompose-angle aim)]
|
(let [{unit-x :x unit-y :y} (physics/decompose-angle aim)]
|
||||||
{:id id
|
{:pos-x pos-x
|
||||||
:pos-x pos-x
|
|
||||||
:pos-y pos-y
|
:pos-y pos-y
|
||||||
:v-x (* unit-x SHELL-SPEED)
|
:v-x (* unit-x SHELL-SPEED)
|
||||||
:v-y (* unit-y SHELL-SPEED)
|
:v-y (* unit-y SHELL-SPEED)
|
||||||
|
|
|
@ -29,9 +29,17 @@
|
||||||
(robot/tick-robot (robots robot-idx) world))
|
(robot/tick-robot (robots robot-idx) world))
|
||||||
starting-world
|
starting-world
|
||||||
(range (count (:robots starting-world))))
|
(range (count (:robots starting-world))))
|
||||||
ticked-shells (map shell/tick-shell shells)
|
ticked-shells (zipmap (keys shells)
|
||||||
live-shells (remove :exploded ticked-shells)
|
(map shell/tick-shell (vals shells)))
|
||||||
exploded-shells (filter :exploded ticked-shells)]
|
|
||||||
|
; TODO: Is this the most idiomatic way to map a hash-map, testing
|
||||||
|
; each value in the hash-map on a predicate and then returning another hash-map?
|
||||||
|
; looks clunky.
|
||||||
|
|
||||||
|
live-shells (into {} (remove #(:exploded (val %))
|
||||||
|
ticked-shells))
|
||||||
|
exploded-shells (into {} (filter #(:exploded (val %))
|
||||||
|
ticked-shells))]
|
||||||
; TODO: make this a real let-binding, that determines
|
; TODO: make this a real let-binding, that determines
|
||||||
; which robots were damaged.
|
; which robots were damaged.
|
||||||
(let [damaged-world ticked-robots-world]
|
(let [damaged-world ticked-robots-world]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user