mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-05-28 23:41:31 +00:00
got shells (mostly) working
This commit is contained in:
parent
0d5f3838ac
commit
0ee2637024
|
@ -11,8 +11,8 @@
|
|||
:pos-y pos-y
|
||||
:v-x (* unit-x SHELL-SPEED)
|
||||
:v-y (* unit-y SHELL-SPEED)
|
||||
:dest-x (* unit-x distance)
|
||||
:dest-y (* unit-y distance)
|
||||
:dest-x (+ pos-x (* unit-x distance))
|
||||
:dest-y (+ pos-y (* unit-y distance))
|
||||
:exploded false}))
|
||||
|
||||
(defn tick-shell
|
||||
|
@ -24,9 +24,10 @@
|
|||
remaining-x (- dest-x pos-x)
|
||||
remaining-y (- dest-y pos-y)]
|
||||
; only need to check one dimension
|
||||
(if (< (Math/abs remaining-x) (Math/abs delta-x))
|
||||
(if (and (< (Math/abs remaining-x) (Math/abs delta-x))
|
||||
(< (Math/abs remaining-y) (Math/abs delta-y)))
|
||||
(merge shell {:pos-x dest-x
|
||||
:pos-y dest-y
|
||||
:exploded true})
|
||||
(merge shell {:pos-x (+ pos-x delta-x)
|
||||
:pox-y (+ pos-y delta-y)})))))
|
||||
:pos-y (+ pos-y delta-y)})))))
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
(ns robotwar.world
|
||||
(:use [clojure.string :only [join]]
|
||||
[robotwar.constants])
|
||||
[robotwar.constants]
|
||||
[clojure.pprint :as pprint])
|
||||
(:require [clj-time.core :as time]
|
||||
[clj-time.periodic :as periodic]
|
||||
[robotwar.robot :as robot]))
|
||||
[robotwar.robot :as robot]
|
||||
[robotwar.shell :as shell]))
|
||||
|
||||
(defn init-world
|
||||
"initialize all the variables for a robot world."
|
||||
|
@ -28,6 +30,7 @@
|
|||
ticked-shells (map shell/tick-shell shells)
|
||||
live-shells (remove :exploded ticked-shells)
|
||||
exploded-shells (filter :exploded ticked-shells)]
|
||||
(println (count ticked-shells))
|
||||
; TODO: make this a real let-binding, that determines
|
||||
; which robots were damaged.
|
||||
(let [damaged-world ticked-robots-world]
|
||||
|
|
Loading…
Reference in New Issue
Block a user