From 6ac4f55ed5a2b8cc342c55f76c974d89d2e6f4c8 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Thu, 17 Jul 2014 09:50:22 +0100 Subject: [PATCH] Added functionality to heightmap to allow a word to be created the size of the supplied heightmap - after all, that's what we will normally want. --- src/mw_engine/heightmap.clj | 14 ++++++++++---- src/mw_engine/natural_rules.clj | 5 +++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/mw_engine/heightmap.clj b/src/mw_engine/heightmap.clj index fc02d72..5efed35 100644 --- a/src/mw_engine/heightmap.clj +++ b/src/mw_engine/heightmap.clj @@ -6,6 +6,7 @@ (ns mw-engine.heightmap (:import [java.awt.image BufferedImage]) (:use mw-engine.utils + mw-engine.world ;; interestingly the imagez load-image is failing for me, while the ;; collage version is problem free. [mikera.image.core :only [filter-image get-pixels]] @@ -58,9 +59,14 @@ altitudes are modified (added to) by the altitudes in the heightmap. It is assumed that the heightmap is at least as large in x and y dimensions as the world. - * `world` a world, as defined in `world.clj`, q.v.; + * `world` a world, as defined in `world.clj`, q.v.; if world is not supplied, + a world the size of the heightmap will be created. * `imagepath` a file path or URL which indicates an image file." - [world imagepath] + ([world imagepath] ;; bizarrely, the collage load-util is working for me, but the imagez version isn't. - (let [heightmap (filter-image (grayscale)(load-image imagepath))] - (apply vector (map #(apply-heightmap-row % heightmap) world)))) + (let [heightmap (filter-image (grayscale)(load-image imagepath))] + (apply vector (map #(apply-heightmap-row % heightmap) world)))) + ([imagepath] + (let [heightmap (filter-image (grayscale)(load-image imagepath)) + world (make-world (.getWidth heightmap) (.getHeight heightmap))] + (apply vector (map #(apply-heightmap-row % heightmap) world))))) \ No newline at end of file diff --git a/src/mw_engine/natural_rules.clj b/src/mw_engine/natural_rules.clj index a7c86ef..6032ca3 100644 --- a/src/mw_engine/natural_rules.clj +++ b/src/mw_engine/natural_rules.clj @@ -1,4 +1,9 @@ ;; A set of MicroWorld rules describing a simplified natural ecosystem. +;; +;; Since the completion of the rule language this is more or less obsolete - +;; there are still a few things that you can do with rules written in Clojure +;; that you can't do in the rule language, but not many and I doubt they're +;; important. (ns mw-engine.natural-rules (:use mw-engine.utils