src/generation/world.lisp @ f17271ef79b7
Add an inventory, player movement and such
author |
Steve Losh <steve@stevelosh.com> |
date |
Sat, 07 Jan 2017 17:08:58 +0000 |
parents |
9a486239bf46 |
children |
(none) |
(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))