mirror of
https://github.com/richardharrington/robotwar.git
synced 2025-02-22 01:29:01 +00:00
trying to fix shells
This commit is contained in:
parent
fe9294bff1
commit
37625c312b
@ -123,7 +123,8 @@
|
||||
GAME-SECONDS-PER-SHOT)]
|
||||
(assoc
|
||||
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))))))})
|
||||
|
||||
(defn get-target-register
|
||||
|
@ -3,12 +3,11 @@
|
||||
(:require [robotwar.physics :as physics]))
|
||||
|
||||
(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,
|
||||
; which should be in constants.
|
||||
(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
|
||||
:v-x (* unit-x SHELL-SPEED)
|
||||
:v-y (* unit-y SHELL-SPEED)
|
||||
|
@ -29,9 +29,17 @@
|
||||
(robot/tick-robot (robots robot-idx) world))
|
||||
starting-world
|
||||
(range (count (:robots starting-world))))
|
||||
ticked-shells (map shell/tick-shell shells)
|
||||
live-shells (remove :exploded ticked-shells)
|
||||
exploded-shells (filter :exploded ticked-shells)]
|
||||
ticked-shells (zipmap (keys shells)
|
||||
(map shell/tick-shell (vals 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
|
||||
; which robots were damaged.
|
||||
(let [damaged-world ticked-robots-world]
|
||||
|
Loading…
x
Reference in New Issue
Block a user