# HG changeset patch # User Steve Losh # Date 1483816491 0 # Node ID 86c388644ac5d47cb99a5275b38a13530b3d39ab # Parent 1c92535d2aecaa0e7171a1fa6a317035b8bdbabb Collapse files diff -r 1c92535d2aec -r 86c388644ac5 antipodes.asd --- a/antipodes.asd Sat Jan 07 19:11:35 2017 +0000 +++ b/antipodes.asd Sat Jan 07 19:14:51 2017 +0000 @@ -22,7 +22,6 @@ (:module "src" :serial t :components ((:file "utilities") - (:file "world-generation") (:module "aspects" :serial t :components ((:file "coordinates") (:file "holdable") diff -r 1c92535d2aec -r 86c388644ac5 src/flavor.lisp --- a/src/flavor.lisp Sat Jan 07 19:11:35 2017 +0000 +++ b/src/flavor.lisp Sat Jan 07 19:14:51 2017 +0000 @@ -30,5 +30,5 @@ (defun random-flavor () (let ((r (random 1.0))) - (cond ((< r 0.50) (animal)) + (cond ((< r 0.20) (animal)) (t (wind))))) diff -r 1c92535d2aec -r 86c388644ac5 src/main.lisp --- a/src/main.lisp Sat Jan 07 19:11:35 2017 +0000 +++ b/src/main.lisp Sat Jan 07 19:14:51 2017 +0000 @@ -28,6 +28,36 @@ (defparameter *food-density* 1/6000) +;;;; Heightmap ---------------------------------------------------------------- +;;; TODO: Switch to something less samey +(defparameter *map-size* 2000) +(defparameter *noise-scale* 0.03) +(defparameter *noise-seed-x* (random 1000.0)) +(defparameter *noise-seed-y* (random 1000.0)) + +(defun make-empty-heightmap () + (make-array (list *map-size* *map-size*) + :element-type 'single-float + :initial-element 0.0)) + +(defun noise-heightmap (heightmap) + (iterate + (with ox = *noise-seed-x*) + (with oy = *noise-seed-x*) + (with scale = *noise-scale*) + (for (val x y) :in-array heightmap) + (setf (aref heightmap x y) + (black-tie:perlin-noise-single-float + (+ ox (* x scale)) + (+ oy (* y scale)) + 0.0)))) + +(defun generate-heightmap () + (let ((heightmap (make-empty-heightmap))) + (noise-heightmap heightmap) + heightmap)) + + ;;;; Colors ------------------------------------------------------------------- (defcolors (+white-black+ charms/ll:COLOR_WHITE charms/ll:COLOR_BLACK) diff -r 1c92535d2aec -r 86c388644ac5 src/world-generation.lisp --- a/src/world-generation.lisp Sat Jan 07 19:11:35 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -(in-package :ap) - -;;;; Parameters --------------------------------------------------------------- -(defparameter *map-size* 2000) -(defparameter *noise-scale* 0.03) -(defparameter *noise-seed-x* (random 1000.0)) -(defparameter *noise-seed-y* (random 1000.0)) - - -;;;; Heightmap ---------------------------------------------------------------- -;;; TODO: Switch to something less samey - -(defun make-empty-heightmap () - (make-array (list *map-size* *map-size*) - :element-type 'single-float - :initial-element 0.0)) - -(defun noise-heightmap (heightmap) - (iterate - (with ox = *noise-seed-x*) - (with oy = *noise-seed-x*) - (with scale = *noise-scale*) - (for (val x y) :in-array heightmap) - (setf (aref heightmap x y) - (black-tie:perlin-noise-single-float - (+ ox (* x scale)) - (+ oy (* y scale)) - 0.0)))) - -(defun generate-heightmap () - (let ((heightmap (make-empty-heightmap))) - (noise-heightmap heightmap) - heightmap))