summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets.lisp6
-rw-r--r--the-price-of-a-cup-of-coffee.lisp37
2 files changed, 41 insertions, 2 deletions
diff --git a/assets.lisp b/assets.lisp
index 0d38f7e..c0522de 100644
--- a/assets.lisp
+++ b/assets.lisp
@@ -107,7 +107,11 @@
(defvar *expression-texture*)
(defvar *backdrop-texture*)
(defvar *sliding-door-texture*)
-(defvar *sliding-door-position* (sdl2:make-rect 800 8 104 138))
+
+(defparameter +sliding-door-open-x+ 800)
+(defparameter +sliding-door-closed-x+ 868)
+(defvar *sliding-door-position*
+ (sdl2:make-rect +sliding-door-closed-x+ 8 104 138))
(defvar *harmony-initialized-p* nil)
(defvar *cold-day-track*)
diff --git a/the-price-of-a-cup-of-coffee.lisp b/the-price-of-a-cup-of-coffee.lisp
index 2038c18..75a29de 100644
--- a/the-price-of-a-cup-of-coffee.lisp
+++ b/the-price-of-a-cup-of-coffee.lisp
@@ -220,7 +220,18 @@
(defmethod update :after ((hero hero) ticks)
(with-slots (pos) hero
(setf (sdl2:rect-x pos)
- (mod (sdl2:rect-x pos) +window-width+))))
+ (mod (sdl2:rect-x pos) +window-width+))
+ (if (and (<= +sliding-door-closed-x+
+ (sdl2:rect-x pos)
+ (+ +sliding-door-closed-x+
+ (sdl2:rect-width *sliding-door-position*)))
+ (<= (sdl2:rect-y pos) (+ +vert-min+ 40)))
+ (when (not *door-open-p*)
+ (open-door))
+ (when *door-open-p*
+ (close-door)))))
+
+
(def-normal-class pedestrian (human)
(comfort-rad 60)
@@ -585,3 +596,27 @@
(setf *to-render-by-y*
(delete p *to-render-by-y*)))
(setf *pedestrians* nil))
+
+
+(defvar *door-open-p* nil)
+
+(defun open-door ()
+ (unless *door-open-p*
+ (setf *door-open-p* t)
+ (push (animate *sliding-door-position* 'sdl2:rect-x +sliding-door-open-x+
+ :start (sdl2:get-ticks)
+ :ease #'animise:cubic-in-out
+ :duration 500)
+ *tweens*)))
+
+(defun close-door ()
+ (when *door-open-p*
+ (setf *door-open-p* nil)
+ (push (animate *sliding-door-position* 'sdl2:rect-x +sliding-door-closed-x+
+ :start (sdl2:get-ticks)
+ :ease #'animise:cubic-in-out
+ :duration 500)
+ *tweens*)))
+
+
+