f5172370bbdb
Collision detection
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Sun, 13 Dec 2015 13:16:39 +0000 |
parents | 251301483006 |
children | cbdc3ce6eb97 |
branches/tags | (none) |
files | src/silt/core.clj |
Changes
--- a/src/silt/core.clj Sun Dec 13 13:12:09 2015 +0000 +++ b/src/silt/core.clj Sun Dec 13 13:16:39 2015 +0000 @@ -103,6 +103,12 @@ [(update-in animal [:energy] #(- % 40)) (clone animal)]) +(defn try-move [[x y :as orig] [dx dy]] + (let [dest (normalize-world-coords [(+ x dx) (+ y dy)])] + (if (contains? @terrain dest) + orig + dest))) + (defn affect-temp [animal] animal) (defn fix-temp [animal] animal) @@ -111,8 +117,7 @@ (defn wander [animal] (update-in animal [:loc] - (fn [[x y] [dx dy]] - (normalize-world-coords [(+ x dx) (+ y dy)])) + try-move (rr/rand-nth directions))) (defn age [animal]