diff --git a/terranostra.lisp b/terranostra.lisp index a4f8ed9..a761822 100644 --- a/terranostra.lisp +++ b/terranostra.lisp @@ -9,15 +9,68 @@ (defvar *debugging* T) +(ql:quickload :croatoan) +(use-package :croatoan) + (load "util.lisp") (load "items.lisp") -(load "biome.lisp") +(load "biomes.lisp") (load "animals.lisp") (load "world.lisp") +(defun user-interface () + "Create the screen on the ncurses interface and hand over to window functions" + ;;TODO + (with-screen (scr :input-echoing nil :input-blocking t :enable-colors t + :cursor-visibility nil :input-reading :unbuffered) + (let* ((width (.width scr)) (height (.height scr)) + (me (list (round (/ width 2)) (round (/ height 2))))) + (setf (.color-pair scr) '(:green :black)) + (draw-test-map scr height width me) + ;(draw-map (floor (/ w 2)) h) + ;(draw-info-panel (ceiling (/ w 2) h)) + (event-case (scr event) + (#\q (return-from event-case)) + (:up (decf (second me)) (draw-test-map scr height width me)) + (:down (incf (second me)) (draw-test-map scr height width me)) + (:left (decf (first me)) (draw-test-map scr height width me)) + (:right (incf (first me)) (draw-test-map scr height width me)))))) + +(defun draw-test-map (scr height width me) + (clear scr) + (box scr) + (dotimes (h height) + (dotimes (w width) + (if (and (= w (first me)) (= h (second me))) + (progn (setf (.color-pair scr) '(:white :black)) + (add-char scr #\X) + (setf (.color-pair scr) '(:green :black))) + (add-char scr #\;))) + (new-line scr)) + (refresh scr)) + + +;;;FIXME my croatoan version doesn't have `with-window` yet, for some reason... +;; (defun draw-map (width height) +;; "Draw a portion of the game map in an ncurses window" +;; ;;TODO +;; (with-window (mapwin :position '(0 0) :width width :height height +;; :cursor-position '(0 0) :input-blocking t :border t) +;; (dotimes (h height) +;; (add mapwin #\. :n -1)))) + +;; (defun draw-info-panel (width height) +;; "Draw the info panel and associated information in an ncurses window" +;; ;;TODO +;; ) + +(defun process-command (event) + ) + ;; Initialize the random state (which would otherwise not be very random...) (setf *random-state* (make-random-state t)) -(create-world 100 "test.world") +;(create-world 100 "test.world") +(user-interface) diff --git a/terranostra.lisp b/terranostra.lisp index a4f8ed9..a761822 100644 --- a/terranostra.lisp +++ b/terranostra.lisp @@ -9,15 +9,68 @@ (defvar *debugging* T) +(ql:quickload :croatoan) +(use-package :croatoan) + (load "util.lisp") (load "items.lisp") -(load "biome.lisp") +(load "biomes.lisp") (load "animals.lisp") (load "world.lisp") +(defun user-interface () + "Create the screen on the ncurses interface and hand over to window functions" + ;;TODO + (with-screen (scr :input-echoing nil :input-blocking t :enable-colors t + :cursor-visibility nil :input-reading :unbuffered) + (let* ((width (.width scr)) (height (.height scr)) + (me (list (round (/ width 2)) (round (/ height 2))))) + (setf (.color-pair scr) '(:green :black)) + (draw-test-map scr height width me) + ;(draw-map (floor (/ w 2)) h) + ;(draw-info-panel (ceiling (/ w 2) h)) + (event-case (scr event) + (#\q (return-from event-case)) + (:up (decf (second me)) (draw-test-map scr height width me)) + (:down (incf (second me)) (draw-test-map scr height width me)) + (:left (decf (first me)) (draw-test-map scr height width me)) + (:right (incf (first me)) (draw-test-map scr height width me)))))) + +(defun draw-test-map (scr height width me) + (clear scr) + (box scr) + (dotimes (h height) + (dotimes (w width) + (if (and (= w (first me)) (= h (second me))) + (progn (setf (.color-pair scr) '(:white :black)) + (add-char scr #\X) + (setf (.color-pair scr) '(:green :black))) + (add-char scr #\;))) + (new-line scr)) + (refresh scr)) + + +;;;FIXME my croatoan version doesn't have `with-window` yet, for some reason... +;; (defun draw-map (width height) +;; "Draw a portion of the game map in an ncurses window" +;; ;;TODO +;; (with-window (mapwin :position '(0 0) :width width :height height +;; :cursor-position '(0 0) :input-blocking t :border t) +;; (dotimes (h height) +;; (add mapwin #\. :n -1)))) + +;; (defun draw-info-panel (width height) +;; "Draw the info panel and associated information in an ncurses window" +;; ;;TODO +;; ) + +(defun process-command (event) + ) + ;; Initialize the random state (which would otherwise not be very random...) (setf *random-state* (make-random-state t)) -(create-world 100 "test.world") +;(create-world 100 "test.world") +(user-interface) diff --git a/world.lisp b/world.lisp index 64275ee..40bcffb 100644 --- a/world.lisp +++ b/world.lisp @@ -142,11 +142,10 @@ ((or (null patch) (eq (patch-biome patch) (get-biome 'stream)))) (setf (patch-biome patch) (get-biome 'stream)))) -(defun create-world (size &optional name (world *world*)) +(defun create-world (size &optional (world *world*)) (setf world NIL) (setf world (init-matrix size)) ;;XXX magic numbers (generate-biomes 20 world) (dotimes (s (round (/ (expt size 2) 500))) - (generate-stream (random size) (random size) world)) - (when name (save-topography name world))) + (generate-stream (random size) (random size) world)))