# HG changeset patch # User Steve Losh # Date 1483799426 0 # Node ID 9a486239bf464b6cc8ff5aed0f70d2f8675ff1a4 # Parent d0c6e89468c247db983a646e87586309711e5bd5 Shuffle shit around diff -r d0c6e89468c2 -r 9a486239bf46 antipodes.asd --- a/antipodes.asd Sat Jan 07 14:16:41 2017 +0000 +++ b/antipodes.asd Sat Jan 07 14:30:26 2017 +0000 @@ -22,8 +22,10 @@ (:module "src" :serial t :components ((:file "utilities") - (:module "gen" :serial t + (:module "generation" :serial t :components ((:file "world"))) - (:module "ent" :serial t + (:module "aspects" :serial t + :components ((:file "coordinates"))) + (:module "entities" :serial t :components ((:file "player"))) (:file "main"))))) diff -r d0c6e89468c2 -r 9a486239bf46 package.lisp --- a/package.lisp Sat Jan 07 14:16:41 2017 +0000 +++ b/package.lisp Sat Jan 07 14:30:26 2017 +0000 @@ -27,7 +27,7 @@ :init-colors )) -(defpackage :ap.gen +(defpackage :ap.generation (:use :cl :iterate @@ -38,7 +38,7 @@ :ap.quickutils) (:export)) -(defpackage :ap.ent +(defpackage :ap.entities (:use :cl :iterate diff -r d0c6e89468c2 -r 9a486239bf46 src/aspects/coordinates.lisp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/aspects/coordinates.lisp Sat Jan 07 14:30:26 2017 +0000 @@ -0,0 +1,2 @@ +(in-package :ap.entities) + diff -r d0c6e89468c2 -r 9a486239bf46 src/ent/player.lisp --- a/src/ent/player.lisp Sat Jan 07 14:16:41 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -(in-package :ap.ent) diff -r d0c6e89468c2 -r 9a486239bf46 src/entities/player.lisp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/entities/player.lisp Sat Jan 07 14:30:26 2017 +0000 @@ -0,0 +1,1 @@ +(in-package :ap.entities) diff -r d0c6e89468c2 -r 9a486239bf46 src/gen/world.lisp --- a/src/gen/world.lisp Sat Jan 07 14:16:41 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -(in-package :ap.gen) - - -(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)) diff -r d0c6e89468c2 -r 9a486239bf46 src/generation/world.lisp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/generation/world.lisp Sat Jan 07 14:30:26 2017 +0000 @@ -0,0 +1,33 @@ +(in-package :ap.generation) + +;;;; 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)) diff -r d0c6e89468c2 -r 9a486239bf46 src/main.lisp --- a/src/main.lisp Sat Jan 07 14:16:41 2017 +0000 +++ b/src/main.lisp Sat Jan 07 14:30:26 2017 +0000 @@ -32,8 +32,6 @@ (+yellow-black+ charms/ll:COLOR_YELLOW charms/ll:COLOR_BLACK) (+green-black+ charms/ll:COLOR_GREEN charms/ll:COLOR_BLACK) (+pink-black+ charms/ll:COLOR_MAGENTA charms/ll:COLOR_BLACK) - - (+black-white+ charms/ll:COLOR_BLACK charms/ll:COLOR_WHITE) ) @@ -99,7 +97,7 @@ ;;;; World Generation --------------------------------------------------------- (defun generate-world% () - (setf *terrain* (ap.gen::generate-heightmap)) + (setf *terrain* (ap.generation::generate-heightmap)) (destructuring-bind (map-width map-height) (array-dimensions *terrain*) (setf *view-x* (truncate map-width 2) *view-y* (truncate map-height 2))))