diff --git a/biomes.lisp b/biomes.lisp index fde3c3e..65fd733 100644 --- a/biomes.lisp +++ b/biomes.lisp @@ -14,8 +14,7 @@ (ground "") (occupants '()) ;an alist of possible occupants and their probabilities (char #\.) ;default map display character - (col 'white)) ;default map display colour - + (col ':white)) ;default map display colour (let ((biome-list NIL)) (defun register-biome (symbol-name biome-object) @@ -37,29 +36,29 @@ (new-biome 'grassland :name "grassland" :ground "tall elephant grass" - :char #\; :col 'yellow + :char #\; :col ':yellow :occupants '((acacia 5) (boulder 1))) ;TODO (new-biome 'forest :name "forest" :ground "leaf litter and small shrubs" - :char #\. :col 'green + :char #\. :col ':green :occupants '((miombo 20) (acacia 10))) ;TODO (new-biome 'stream :name "stream" :ground "shallow flowing water" - :char #\~ :col 'blue + :char #\~ :col ':blue :occupants '()) ;TODO (new-biome 'swamp :name "swamp" :ground "short sedge grass growing on boggy black soil" - :char #\w :col 'green + :char #\w :col ':green :occupants '()) ;TODO (new-biome 'hill :name "hill" :ground "hard, stony soil" - :char #\m :col 'white + :char #\m :col ':white :occupants '((boulder 15))) ;TODO diff --git a/biomes.lisp b/biomes.lisp index fde3c3e..65fd733 100644 --- a/biomes.lisp +++ b/biomes.lisp @@ -14,8 +14,7 @@ (ground "") (occupants '()) ;an alist of possible occupants and their probabilities (char #\.) ;default map display character - (col 'white)) ;default map display colour - + (col ':white)) ;default map display colour (let ((biome-list NIL)) (defun register-biome (symbol-name biome-object) @@ -37,29 +36,29 @@ (new-biome 'grassland :name "grassland" :ground "tall elephant grass" - :char #\; :col 'yellow + :char #\; :col ':yellow :occupants '((acacia 5) (boulder 1))) ;TODO (new-biome 'forest :name "forest" :ground "leaf litter and small shrubs" - :char #\. :col 'green + :char #\. :col ':green :occupants '((miombo 20) (acacia 10))) ;TODO (new-biome 'stream :name "stream" :ground "shallow flowing water" - :char #\~ :col 'blue + :char #\~ :col ':blue :occupants '()) ;TODO (new-biome 'swamp :name "swamp" :ground "short sedge grass growing on boggy black soil" - :char #\w :col 'green + :char #\w :col ':green :occupants '()) ;TODO (new-biome 'hill :name "hill" :ground "hard, stony soil" - :char #\m :col 'white + :char #\m :col ':white :occupants '((boulder 15))) ;TODO diff --git a/terranostra.lisp b/terranostra.lisp index a761822..99f4696 100644 --- a/terranostra.lisp +++ b/terranostra.lisp @@ -25,45 +25,53 @@ (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)))))) + (me (list (round (/ width 4)) (round (/ height 2))))) + (with-windows ((mapwin :position '(0 0) :input-blocking t :border t + :width (floor (/ width 2)) :height height) + (infowin :position (list 0 (floor (/ width 2))) + :input-blocking t :border t + :width (ceiling (/ width 2)) :height height)) + (draw-map mapwin me) + (draw-info-panel infowin) + (event-case (scr event) + (#\q (return-from event-case)) + (:up (decf (second me)) (draw-map mapwin me)) + (:down (incf (second me)) (draw-map mapwin me)) + (:left (decf (first me)) (draw-map mapwin me)) + (:right (incf (first me)) (draw-map mapwin 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)) +(defun draw-map (win me) + "Draw a portion of the game map in an ncurses window" + ;;FIXME + (setf (.color-pair win) '(:white :black)) + (box win) + (setf (.cursor-position win) '(1 1)) + (let ((x0 (- (first me) (round (/ (.width win) 2)))) + (y0 (- (second me) (round (/ (.height win) 2))))) + (dotimes (h (- (.height win) 1)) + (dotimes (w (- (.width win) 2)) + (let ((p (coord (+ w x0 1) (+ h y0 1)))) + (if (null p) (add-char win #\space) + ;;TODO draw features + (if (and (= (first (patch-pos p)) (first me)) + (= (second (patch-pos p)) (second me))) + (progn (setf (.color-pair win) '(:white :black)) + (add-char win #\X)) + (progn + (setf (.color-pair win) + (list (biome-col (patch-biome p)) :black)) + (add-char win + (biome-char (patch-biome p)))))))) + (setf (.cursor-position win) (list (+ h 1) 1)) + (refresh win)))) - -;;;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 draw-info-panel (win) + "Draw the info panel and associated information in an ncurses window" + ;;TODO + (box win) + (setf (.cursor-position win) '(1 1)) + (add-string win "This is the information panel.") + (refresh win)) (defun process-command (event) ) @@ -71,6 +79,5 @@ ;; Initialize the random state (which would otherwise not be very random...) (setf *random-state* (make-random-state t)) -;(create-world 100 "test.world") - +(setf *world* (create-world 100)) (user-interface)