From 06e875b27180286391abae4f33f9e9d318cd300c Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Tue, 27 Jun 2023 21:36:13 -0500 Subject: [PATCH] Create the scaffodling for an inventory menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All it does right now is print your raw list of items. That’s OK for now! =w= --- flora-search-aurora.asd | 1 + inventory.lisp | 65 +++++++++++++++++++++++++++++++++++++++++ overworld.lisp | 6 ++-- 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 inventory.lisp diff --git a/flora-search-aurora.asd b/flora-search-aurora.asd index 1bc0448..28c197a 100644 --- a/flora-search-aurora.asd +++ b/flora-search-aurora.asd @@ -7,6 +7,7 @@ (:file "display") (:file "input") (:file "ui") + (:file "inventory") (:file "overworld.util") (:file "overworld") (:file "dialogue") diff --git a/inventory.lisp b/inventory.lisp new file mode 100644 index 0000000..66cc70a --- /dev/null +++ b/inventory.lisp @@ -0,0 +1,65 @@ + +;;;; Copyright Β© 2023, Jaidyn Ann +;;;; +;;;; This program is free software: you can redistribute it and/or +;;;; modify it under the terms of the GNU General Public License as +;;;; published by the Free Software Foundation, either version 3 of +;;;; the License, or (at your option) any later version. +;;;; +;;;; This program is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;;; GNU General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU General Public License +;;;; along with this program. If not, see . + +;;;; FLORA-SEARCH-AURORA.INVENTORY +;;;; The menu for inventory selection/management. + +(defpackage :flora-search-aurora.inventory + (:nicknames :fsa.inv :inventory :πŸŽ’) + (:use :cl) + (:export #:inventory-state #:make-inventory-state)) + +(in-package :flora-search-aurora.inventory) + + +;;; β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” +;;; Inventory loop logic +;;; β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” +(defun inventory-state-update (map) + (if (and (listen) + (let ((input (getf (⌨:read-gamefied-char-plist) :semantic))) + (or (eq input '⌨:πŸ†—) + (eq input '⌨:❎)))) + (values nil + (list :map map)) + 't)) + + + +;;; β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” +;;; Inventory loop drawing +;;; β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” +(defun inventory-state-draw (matrix items) + (πŸ“‹:render-string matrix (format nil "~A" items) '(:x 0 :y 0))) + + + +;;; β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” +;;; Inventory loop +;;; β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” +(defun inventory-state (matrix &key map) + "A state-function for use with STATE-LOOP." + (sleep .02) + (inventory-state-draw matrix (gethash :items map)) + (inventory-state-update map)) + + +(defun make-inventory-state (map) + "Return a state-function for inventory-listing, for use with STATE-LOOP." + (lambda (matrix &key (map map)) + (apply #'πŸŽ’:inventory-state + (list matrix :map map)))) + diff --git a/overworld.lisp b/overworld.lisp index b4a1e61..44ea661 100644 --- a/overworld.lisp +++ b/overworld.lisp @@ -224,12 +224,12 @@ Returns parameters to be used in the next invocation of OVERWORLD-STATE." (if interaction (apply (string->symbol interaction) (list map interactee-id)) (list :map map)))) - ;; The pause-menu… -;; ((plist = input '(:modifier nil :char #\Esc))) + ('⌨:❎ + (πŸŽ’:make-inventory-state map)) ;; Simple up-down-left-right movements ('⌨:β†’ (move-player map :Ξ”x 1)) - ('⌨:β†’ + ('⌨:← (move-player map :Ξ”x -1)) ('⌨:↑ (move-player map :Ξ”y -1))