diff options
author | Boutade <thegoofist@protonmail.com> | 2019-10-11 07:41:46 -0500 |
---|---|---|
committer | Boutade <thegoofist@protonmail.com> | 2019-10-11 07:41:46 -0500 |
commit | 89a57373ad50be71d863bba415f40e04467e560a (patch) | |
tree | 084a31a111fd61fb64767b475f09372218ee93b8 /the-price-of-a-cup-of-coffee.lisp |
initial commit
Diffstat (limited to 'the-price-of-a-cup-of-coffee.lisp')
-rw-r--r-- | the-price-of-a-cup-of-coffee.lisp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/the-price-of-a-cup-of-coffee.lisp b/the-price-of-a-cup-of-coffee.lisp new file mode 100644 index 0000000..50f8cf3 --- /dev/null +++ b/the-price-of-a-cup-of-coffee.lisp @@ -0,0 +1,59 @@ +;;;; the-price-of-a-cup-of-coffee.lisp + +(in-package #:the-price-of-a-cup-of-coffee) + +(defun make-keyword-symbol (s) + "Makes a keyword from a string or symbol." + (let ((s (format nil "~a" s))) + (read-from-string + (format nil ":~a" + (substitute #\- #\Space s))))) + + +(defmacro def-normal-class (name super &rest slots) + "Defines a class with the given name and slots, with accessors and initargs for each slot." + `(defclass ,name ,super + (,@(loop :for slot :in slots + :when (consp slot) + :collect (list (car slot) + :accessor (car slot) + :initform (cadr slot) + :initarg (make-keyword-symbol (car slot))) + :else + :collect (list slot + :accessor slot + :initform nil + :initarg (make-keyword-symbol slot)))))) + +(def-normal-class pedestrian () + (walk-vec (list 2 0)) + (comfort-rad 60) + (react-per-sec 1) + (anger 0.1) + (kindness 0.02) + (generosity 0.25) + (vulnerability 3)) + + +(def-normal-class () + (stress 0) + (money 0) + (coldness 0) + (sick-p nil) + (speed 5) + (relax-rate 1) + + +(defun main () + (sdl2:with-init (:everything) + (sdl2:with-window (win :w 800 :h 600 :title "The Price Of A Cup Of Coffee" :flags '(:shown)) + (sdl2:with-renderer (rndr win :flags '(:accelerated)) + (sdl2:with-event-loop (:method :poll) + (:keydown (:keysym keysym) + (if (sdl2:scancode= (sdl2:scancode-value keysym) :scancode-escape) + (sdl2:push-event :quit))) + (:idle ()) + + (:quit () t)))))) + + |