summaryrefslogtreecommitdiff
path: root/the-price-of-a-cup-of-coffee.lisp
diff options
context:
space:
mode:
authorBoutade <thegoofist@protonmail.com>2019-10-17 16:38:22 -0500
committerBoutade <thegoofist@protonmail.com>2019-10-17 16:38:22 -0500
commit4561cf44623c7a8d42eb76ee0149a0c308dcfd08 (patch)
treeaee47f637a268271640a0eb633df2acd7b5af8b9 /the-price-of-a-cup-of-coffee.lisp
parentcd038fc15dd9a1bcaab064c605a4df1f11488cab (diff)
sliding door
Diffstat (limited to 'the-price-of-a-cup-of-coffee.lisp')
-rw-r--r--the-price-of-a-cup-of-coffee.lisp37
1 files changed, 36 insertions, 1 deletions
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*)))
+
+
+