diff --git a/ncurses_example.lisp b/ncurses_example.lisp deleted file mode 100644 index 2c58448..0000000 --- a/ncurses_example.lisp +++ /dev/null @@ -1,16 +0,0 @@ - -(in-package :croatoan) - -(defun test1 () - (with-screen (scr :input-echoing nil :input-blocking t :enable-colors t) - (clear scr) - (move scr 2 0) - (format scr "Type chars. Type q to quit.~%~%") - (refresh scr) - (setf (.color-pair scr) '(:yellow :red) - (.attributes scr) '(:bold)) - (event-case (scr event) - (#\q (return-from event-case)) - (otherwise (princ event scr) - (refresh scr))))) - diff --git a/ncurses_example.lisp b/ncurses_example.lisp deleted file mode 100644 index 2c58448..0000000 --- a/ncurses_example.lisp +++ /dev/null @@ -1,16 +0,0 @@ - -(in-package :croatoan) - -(defun test1 () - (with-screen (scr :input-echoing nil :input-blocking t :enable-colors t) - (clear scr) - (move scr 2 0) - (format scr "Type chars. Type q to quit.~%~%") - (refresh scr) - (setf (.color-pair scr) '(:yellow :red) - (.attributes scr) '(:bold)) - (event-case (scr event) - (#\q (return-from event-case)) - (otherwise (princ event scr) - (refresh scr))))) - diff --git a/terranostra.lisp b/terranostra.lisp index 60045ad..6dfb61f 100644 --- a/terranostra.lisp +++ b/terranostra.lisp @@ -27,22 +27,21 @@ (let* ((width (.width scr)) (height (1- (.height scr))) (me (list (round (/ width 4)) (halve height)))) (with-windows ((mapwin :position '(0 0) :input-blocking t :border t - :width (halve width 'down) :height height) - (playerwin :position (list 0 (halve width 'down)) + :width (- width 51) :height height) + (playerwin :position (list 0 (- width 50)) :input-blocking t :border t - :width (halve width 'up) - :height (halve height 'down)) + :width 50 :height (halve height 'down)) (placewin :input-blocking t :border t - :position (list (halve height) - (halve width 'down)) - :width (halve width 'up) - :height (halve height 'down)) + :position (list (halve height) (- width 50)) + :width 50 :height (halve height 'down)) (newswin :input-blocking t :position (list height 0) :width width :height 1)) (update-ui mapwin playerwin placewin newswin me) + (refresh scr) (event-case (scr event) (#\q (return-from event-case)) + (#\n (draw-menu (message-window))) (:up (decf (second me)) (update-ui mapwin playerwin placewin newswin me)) (:down (incf (second me)) (update-ui mapwin playerwin @@ -50,7 +49,8 @@ (:left (decf (first me)) (update-ui mapwin playerwin placewin newswin me)) (:right (incf (first me)) (update-ui mapwin playerwin - placewin newswin me))))))) + placewin newswin me)) + (otherwise (notify (string event)))))))) (defun update-ui (mapwin playerwin placewin newswin me) "Update all four UI elements" @@ -102,18 +102,43 @@ (add-string win "This is the place panel.") (refresh win)) -(defun draw-news-panel (win) - "Draw a thin panel at the bottom of the screen to display news items." - ;;TODO - (setf (.cursor-position win) '(0 0)) - (add-string win "This is the news panel.") - (refresh win)) +(let ((news '("Press h for help."))) + (defun draw-news-panel (win) + "Draw a thin panel at the bottom of the screen to display news items." + ;;TODO + (clear win) + (setf (.cursor-position win) '(0 0)) + (add-string win (car news)) + (refresh win)) + + (defun notify (news-string) + "Append a string to the news to notify the user." + (setf news (cons news-string news))) + + + (defun message-window () + "Return a dialog window with the last game messages." + (make-instance 'dialog-window + :input-blocking t + :items (mapcar + #'(lambda (n) (string-from-list (list "*" n) " ")) + news) + :center t + :border t + :layout nil + :title "Game messages" + :max-item-length 50))) + ;:scrolled-layout '(10 1) + ;; :message-height 2 + ;; :message-text "Press b to go back." + ;; :event-handlers '((#\b #'exit-event-loop))))) (defun process-command (event) + ;;TODO ) ;; Initialize the random state (which would otherwise not be very random...) (setf *random-state* (make-random-state t)) -(setf *world* (create-world 200)) +(setf *world* (create-world 500)) (user-interface) diff --git a/ncurses_example.lisp b/ncurses_example.lisp deleted file mode 100644 index 2c58448..0000000 --- a/ncurses_example.lisp +++ /dev/null @@ -1,16 +0,0 @@ - -(in-package :croatoan) - -(defun test1 () - (with-screen (scr :input-echoing nil :input-blocking t :enable-colors t) - (clear scr) - (move scr 2 0) - (format scr "Type chars. Type q to quit.~%~%") - (refresh scr) - (setf (.color-pair scr) '(:yellow :red) - (.attributes scr) '(:bold)) - (event-case (scr event) - (#\q (return-from event-case)) - (otherwise (princ event scr) - (refresh scr))))) - diff --git a/terranostra.lisp b/terranostra.lisp index 60045ad..6dfb61f 100644 --- a/terranostra.lisp +++ b/terranostra.lisp @@ -27,22 +27,21 @@ (let* ((width (.width scr)) (height (1- (.height scr))) (me (list (round (/ width 4)) (halve height)))) (with-windows ((mapwin :position '(0 0) :input-blocking t :border t - :width (halve width 'down) :height height) - (playerwin :position (list 0 (halve width 'down)) + :width (- width 51) :height height) + (playerwin :position (list 0 (- width 50)) :input-blocking t :border t - :width (halve width 'up) - :height (halve height 'down)) + :width 50 :height (halve height 'down)) (placewin :input-blocking t :border t - :position (list (halve height) - (halve width 'down)) - :width (halve width 'up) - :height (halve height 'down)) + :position (list (halve height) (- width 50)) + :width 50 :height (halve height 'down)) (newswin :input-blocking t :position (list height 0) :width width :height 1)) (update-ui mapwin playerwin placewin newswin me) + (refresh scr) (event-case (scr event) (#\q (return-from event-case)) + (#\n (draw-menu (message-window))) (:up (decf (second me)) (update-ui mapwin playerwin placewin newswin me)) (:down (incf (second me)) (update-ui mapwin playerwin @@ -50,7 +49,8 @@ (:left (decf (first me)) (update-ui mapwin playerwin placewin newswin me)) (:right (incf (first me)) (update-ui mapwin playerwin - placewin newswin me))))))) + placewin newswin me)) + (otherwise (notify (string event)))))))) (defun update-ui (mapwin playerwin placewin newswin me) "Update all four UI elements" @@ -102,18 +102,43 @@ (add-string win "This is the place panel.") (refresh win)) -(defun draw-news-panel (win) - "Draw a thin panel at the bottom of the screen to display news items." - ;;TODO - (setf (.cursor-position win) '(0 0)) - (add-string win "This is the news panel.") - (refresh win)) +(let ((news '("Press h for help."))) + (defun draw-news-panel (win) + "Draw a thin panel at the bottom of the screen to display news items." + ;;TODO + (clear win) + (setf (.cursor-position win) '(0 0)) + (add-string win (car news)) + (refresh win)) + + (defun notify (news-string) + "Append a string to the news to notify the user." + (setf news (cons news-string news))) + + + (defun message-window () + "Return a dialog window with the last game messages." + (make-instance 'dialog-window + :input-blocking t + :items (mapcar + #'(lambda (n) (string-from-list (list "*" n) " ")) + news) + :center t + :border t + :layout nil + :title "Game messages" + :max-item-length 50))) + ;:scrolled-layout '(10 1) + ;; :message-height 2 + ;; :message-text "Press b to go back." + ;; :event-handlers '((#\b #'exit-event-loop))))) (defun process-command (event) + ;;TODO ) ;; Initialize the random state (which would otherwise not be very random...) (setf *random-state* (make-random-state t)) -(setf *world* (create-world 200)) +(setf *world* (create-world 500)) (user-interface) diff --git a/world.lisp b/world.lisp index 4fbd4db..bb4e9c4 100644 --- a/world.lisp +++ b/world.lisp @@ -172,6 +172,6 @@ (let ((world (init-matrix size))) ;;XXX magic numbers (generate-biomes 10 world) - (dotimes (s (round (/ (expt size 2) 1000))) + (dotimes (s (round (/ (expt size 2) 2000))) (generate-stream (random size) (random size) world)) world))