summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoutade <thegoofist@protonmail.com>2019-10-19 19:16:00 -0500
committerBoutade <thegoofist@protonmail.com>2019-10-19 19:16:00 -0500
commit4597a26e0446f71049354c4ec292846941610189 (patch)
tree703ce4b1676e0072432d78efa6f4636299e3b83e
parent110254a67072267ef4c03c49247ddf03c028277f (diff)
better resets
-rw-r--r--the-price-of-a-cup-of-coffee.lisp24
1 files changed, 18 insertions, 6 deletions
diff --git a/the-price-of-a-cup-of-coffee.lisp b/the-price-of-a-cup-of-coffee.lisp
index 75b2f0f..a3cd1fd 100644
--- a/the-price-of-a-cup-of-coffee.lisp
+++ b/the-price-of-a-cup-of-coffee.lisp
@@ -247,9 +247,10 @@
(collision-check ped)
- (when (or (< (sdl2:rect-x pos) -50)
- (< +window-width+ (sdl2:rect-x pos)))
- (reset-pedestrian ped))))
+ (when (or (< (sdl2:rect-x pos) -65)
+ (< (+ 65 +window-width+) (sdl2:rect-x pos)))
+ (remove-pedestrian ped))))
+
(defmethod update ((game (eql :game)) time)
(update *nance* time)
@@ -422,6 +423,7 @@
punker))
(defun add-pedestrian (ped)
+ (reset-pedestrian ped)
(push ped *pedestrians*)
(push ped *to-render-by-y*))
@@ -720,9 +722,19 @@
(setf *human-frame-pause* (/ 1000 n)))
(defun reset-pedestrian (ped)
- (setf (already-asked ped) nil)
- (setf (sdl2:rect-y (pos ped)) (random-y-pos))
- (setf (sdl2:rect-x (pos ped)) -49))
+ (with-slots (already-asked pos walk-vec walk-speed) ped
+ (setf already-asked nil)
+ (setf (sdl2:rect-y pos) (random-y-pos))
+ (setf (cdr walk-vec) 0)
+ (if (cointoss)
+ (progn
+ (setf (sdl2:rect-x pos) -64)
+ (setf (car walk-vec) walk-speed))
+ (progn
+ (setf (sdl2:rect-x pos) (+ 64 +window-width+))
+ (setf (car walk-vec) (* -1 walk-speed))))
+ (set-walk-face-by-walk-vec ped)))
+
(defun snap-hit-box-to (human hitbox)
(setf (sdl2:rect-x hitbox) (x-pos human))