~octaspire/crates2

26be0b8195b59e99cb871aded46d2a2f1c176da2 — octaspire 6 months ago ee57a2c
Fix peeking and turnstiles, add :restart and level

  * Fix peeking in test runner because of the larger levels
  * Make pulled not to pass turnstiles
  * Add :restart input
  * Add level
6 files changed, 200 insertions(+), 9 deletions(-)

M .builds/debian_stretch.yml
M src/levels.lisp
M src/main.lisp
M src/pulled.lisp
M src/textual.lisp
M src/turnstiles.lisp
M .builds/debian_stretch.yml => .builds/debian_stretch.yml +2 -2
@@ 16,5 16,5 @@ tasks:
        make test
    - peek-results: |
        cd ~/quicklisp/local-projects/crates2
        head -n 42 got.txt
        tail -n 40 got.txt
        head -n 50 got.txt
        tail -n 48 got.txt

M src/levels.lisp => src/levels.lisp +165 -2
@@ 14,7 14,7 @@
;; limitations under the License.
(in-package :crates2)

(defparameter *num-levels* 20)
(defparameter *num-levels* 21)

(defun load-level (index)
  (ecase index


@@ 293,5 293,168 @@
                    (make-instance 'wall          :x 3  :y 8 :z 0)
                    (make-instance 'slope-en      :x 6  :y 8 :z 0)
                    (make-instance 'slope-wn      :x 11 :y 8 :z 0)
                    (make-instance 'wall          :x 5  :y 9 :z 0))))))
                    (make-instance 'wall          :x 5  :y 9 :z 0))))
    (20 (list (list nil nil
                    :east nil nil nil nil nil
                    :west nil nil
                    :north nil nil
                    :south nil nil
                    :east nil nil nil
                    :north nil nil
                    :east nil nil nil
                    :west nil nil
                    :north nil nil nil
                    :south nil nil nil
                    :east nil nil nil nil
                    :north nil nil nil
                    :east nil nil nil nil nil
                    :west nil nil
                    :north nil nil nil
                    :south nil nil nil
                    :east nil nil nil nil
                    :north nil nil nil
                    :west nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
                    :north nil nil nil
                    :east nil nil nil nil
                    :south nil nil nil nil
                    :north nil nil nil nil
                    :east nil nil nil nil
                    :south nil nil nil nil
                    :north nil nil nil nil
                    :east nil nil nil nil
                    :south nil nil nil nil
                    :north nil nil nil nil nil
                    :east nil nil nil nil nil
                    :south nil nil nil nil nil
                    :west nil nil nil nil
                    :south nil
                    :north nil nil nil nil nil
                    :east nil nil nil nil
                    :south nil nil nil
                    :west nil nil nil nil
                    :north nil
                    :west nil nil
                    :south nil
                    :west nil nil
                    :south nil
                    :north nil nil nil
                    :east nil nil nil nil nil nil nil nil
                    :south nil nil nil
                    :west nil nil
                    :north nil
                    :west nil nil
                    :north nil
                    :west nil nil
                    :south nil
                    :west nil nil
                    :north nil
                    :west nil nil
                    :north nil
                    :west nil nil
                    :south nil
                    :west nil nil
                    :south nil
                    :north nil nil nil
                    :east nil nil nil nil nil nil nil nil nil nil nil nil
                    :south nil nil nil
                    :west nil nil
                    :north nil
                    :west nil nil
                    :north nil
                    :west nil nil
                    :south nil nil nil
                    :west nil nil
                    :north nil
                    :west nil nil
                    :south nil
                    :west nil nil
                    :north nil
                    :west)
              (list (make-instance 'wall          :x 0  :y 0 :z 0)
                    (make-instance 'wall          :x 1  :y 0 :z 0)
                    (make-instance 'wall          :x 2  :y 0 :z 0)
                    (make-instance 'wall          :x 3  :y 0 :z 0)
                    (make-instance 'wall          :x 4  :y 0 :z 0)
                    (make-instance 'wall          :x 5  :y 0 :z 0)
                    (make-instance 'wall          :x 6  :y 0 :z 0)
                    (make-instance 'wall          :x 7  :y 0 :z 0)
                    (make-instance 'wall          :x 8  :y 0 :z 0)
                    (make-instance 'wall          :x 9  :y 0 :z 0)
                    (make-instance 'wall          :x 10 :y 0 :z 0)
                    (make-instance 'wall          :x 11 :y 0 :z 0)
                    (make-instance 'wall          :x 12 :y 0 :z 0)
                    (make-instance 'wall          :x 13 :y 0 :z 0)
                    (make-instance 'wall          :x 14 :y 0 :z 0)
                    (make-instance 'wall          :x 15 :y 0 :z 0)
                    (make-instance 'wall          :x 16 :y 0 :z 0)
                    (make-instance 'wall          :x 17 :y 0 :z 0)
                    (make-instance 'wall          :x 18 :y 0 :z 0)
                    (make-instance 'wall          :x 0  :y 1 :z 0)
                    (make-instance 'block-counter :x 6  :y 1 :z 0 :count 1)
                    (make-instance 'block-counter :x 10 :y 1 :z 0 :count 1)
                    (make-instance 'block-counter :x 14 :y 1 :z 0 :count 1)
                    (make-instance 'key           :x 17 :y 1 :z 0)
                    (make-instance 'wall          :x 18 :y 1 :z 0)
                    (make-instance 'wall          :x 0  :y 2 :z 0)
                    (make-instance 'wall          :x 2  :y 2 :z 0)
                    (make-instance 'wall          :x 3  :y 2 :z 0)
                    (make-instance 'wall          :x 6  :y 2 :z 0)
                    (make-instance 'wall          :x 7  :y 2 :z 0)
                    (make-instance 'wall          :x 10 :y 2 :z 0)
                    (make-instance 'wall          :x 11 :y 2 :z 0)
                    (make-instance 'wall          :x 14 :y 2 :z 0)
                    (make-instance 'wall          :x 15 :y 2 :z 0)
                    (make-instance 'wall          :x 16 :y 2 :z 0)
                    (make-instance 'turnstile-s   :x 17 :y 2 :z 0)
                    (make-instance 'wall          :x 18 :y 2 :z 0)
                    (make-instance 'wall          :x 0  :y 3 :z 0)
                    (make-instance 'pulled        :x 5  :y 3 :z 0 :north t :south t)
                    (make-instance 'pulled        :x 9 :y 3 :z 0 :north t :south t)
                    (make-instance 'pulled        :x 13 :y 3 :z 0 :north t :south t)
                    (make-instance 'wall          :x 18 :y 3 :z 0)
                    (make-instance 'wall          :x 0  :y 4 :z 0)
                    (make-instance 'wall          :x 1  :y 4 :z 0)
                    (make-instance 'wall          :x 2  :y 4 :z 0)
                    (make-instance 'wall          :x 3  :y 4 :z 0)
                    (make-instance 'wall          :x 4  :y 4 :z 0)
                    (make-instance 'wall          :x 6  :y 4 :z 0)
                    (make-instance 'wall          :x 7  :y 4 :z 0)
                    (make-instance 'wall          :x 8  :y 4 :z 0)
                    (make-instance 'wall          :x 10 :y 4 :z 0)
                    (make-instance 'wall          :x 11 :y 4 :z 0)
                    (make-instance 'wall          :x 12 :y 4 :z 0)
                    (make-instance 'wall          :x 14 :y 4 :z 0)
                    (make-instance 'wall          :x 15 :y 4 :z 0)
                    (make-instance 'wall          :x 16 :y 4 :z 0)
                    (make-instance 'wall          :x 18 :y 4 :z 0)
                    (make-instance 'exit          :x 0  :y 5 :z 0)
                    (make-instance 'player        :x 2  :y 5 :z 0)
                    (make-instance 'slope-ws      :x 6  :y 5 :z 0)
                    (make-instance 'slope-ws      :x 10 :y 5 :z 0)
                    (make-instance 'slope-ws      :x 14 :y 5 :z 0)
                    (make-instance 'wall          :x 18 :y 5 :z 0)
                    (make-instance 'wall          :x 0  :y 6 :z 0)
                    (make-instance 'wall          :x 4  :y 6 :z 0)
                    (make-instance 'wall          :x 8  :y 6 :z 0)
                    (make-instance 'wall          :x 12 :y 6 :z 0)
                    (make-instance 'wall          :x 18 :y 6 :z 0)
                    (make-instance 'wall          :x 0  :y 7 :z 0)
                    (make-instance 'wall          :x 1  :y 7 :z 0)
                    (make-instance 'wall          :x 2  :y 7 :z 0)
                    (make-instance 'wall          :x 3  :y 7 :z 0)
                    (make-instance 'wall          :x 4  :y 7 :z 0)
                    (make-instance 'pulled        :x 5  :y 7 :z 0 :north t)
                    (make-instance 'wall          :x 6  :y 7 :z 0)
                    (make-instance 'wall          :x 7  :y 7 :z 0)
                    (make-instance 'wall          :x 8  :y 7 :z 0)
                    (make-instance 'pulled        :x 9  :y 7 :z 0 :north t)
                    (make-instance 'wall          :x 10 :y 7 :z 0)
                    (make-instance 'wall          :x 11 :y 7 :z 0)
                    (make-instance 'wall          :x 12 :y 7 :z 0)
                    (make-instance 'pulled        :x 13 :y 7 :z 0 :north t)
                    (make-instance 'wall          :x 14 :y 7 :z 0)
                    (make-instance 'wall          :x 15 :y 7 :z 0)
                    (make-instance 'wall          :x 16 :y 7 :z 0)
                    (make-instance 'wall          :x 17 :y 7 :z 0)
                    (make-instance 'wall          :x 18 :y 7 :z 0))))))


M src/main.lisp => src/main.lisp +7 -4
@@ 25,8 25,8 @@
(defparameter *running* t)
(defparameter *level* nil)
(defparameter *created* nil)
(defparameter *next-level* 19)
(defparameter *level-width* 18)
(defparameter *next-level* 20)
(defparameter *level-width* 20)
(defparameter *level-height* 15)
(defparameter *frame-duration-default* 0.25) ; Not zeroed in test mode.
(defparameter *frame-duration* *frame-duration-default*) ; Zeroed in test mode.


@@ 98,8 98,11 @@ This is similar to 'test' but runs much slower."
             (let ((input (ui-input)))
               (when input
                 (setf *input* (cons input *input*))
                 (when (eq input :back) (running nil))))
             (update *level*)
                 (case input
                   (:back    (running nil))
                   (:restart (setf *next-level* *level-number*)))))
             (unless *next-level*
               (update *level*))
             (when *next-level*
               (load-next-level))
             (incf *update-counter*)

M src/pulled.lisp => src/pulled.lisp +1 -1
@@ 101,7 101,7 @@
            :idle))
  (setf (pulled-puller self) (if on puller nil))
  (let ((side (on-which-side-is-other self puller 1)))
    (setf (velocity self) (if on side :zero))))
    (setf (velocity self) side)))

(defmethod collide ((self pulled) (target player))
  (when (eq (crate-state self) :idle)

M src/textual.lisp => src/textual.lisp +1 -0
@@ 163,6 163,7 @@
      (#\a :west)
      (#\d :east)
      (#\q :back)
      (#\r :restart)
      (otherwise nil))))

(defun ui-maybe-read-input ()

M src/turnstiles.lisp => src/turnstiles.lisp +24 -0
@@ 26,6 26,9 @@
(defmethod visual ((self turnstile-e1))
  (list "turnstile-e1"))

(defmethod collide ((self turnstile-e1) (target pulled))
  nil)

(defmethod collide ((self turnstile-e1) (target moving))
  (let ((side (on-which-side-is-other self target)))
    (case side


@@ 41,6 44,9 @@
(defmethod visual ((self turnstile-w1))
  (list "turnstile-w1"))

(defmethod collide ((self turnstile-w1) (target pulled))
  nil)

(defmethod collide ((self turnstile-w1) (target moving))
  (let ((side (on-which-side-is-other self target)))
    (case side


@@ 55,6 61,9 @@
(defmethod visual ((self turnstile-n1))
  (list "turnstile-n1"))

(defmethod collide ((self turnstile-n1) (target pulled))
  nil)

(defmethod collide ((self turnstile-n1) (target moving))
  (let ((side (on-which-side-is-other self target)))
    (case side


@@ 69,6 78,9 @@
(defmethod visual ((self turnstile-s1))
  (list "turnstile-s1"))

(defmethod collide ((self turnstile-s1) (target pulled))
  nil)

(defmethod collide ((self turnstile-s1) (target moving))
  (let ((side (on-which-side-is-other self target)))
    (case side


@@ 83,6 95,9 @@
(defmethod visual ((self turnstile-e))
  (list "turnstile-e"))

(defmethod collide ((self turnstile-e) (target pulled))
  nil)

(defmethod collide ((self turnstile-e) (target moving))
  (let ((side (on-which-side-is-other self target)))
    (case side


@@ 99,6 114,9 @@
(defmethod visual ((self turnstile-w))
  (list "turnstile-w"))

(defmethod collide ((self turnstile-w) (target pulled))
  nil)

(defmethod collide ((self turnstile-w) (target moving))
  (let ((side (on-which-side-is-other self target)))
    (case side


@@ 114,6 132,9 @@
(defmethod visual ((self turnstile-n))
  (list "turnstile-n"))

(defmethod collide ((self turnstile-n) (target pulled))
  nil)

(defmethod collide ((self turnstile-n) (target moving))
  (let ((side (on-which-side-is-other self target)))
    (case side


@@ 129,6 150,9 @@
(defmethod visual ((self turnstile-s))
  (list "turnstile-s"))

(defmethod collide ((self turnstile-s) (target pulled))
  nil)

(defmethod collide ((self turnstile-s) (target moving))
  (let ((side (on-which-side-is-other self target)))
    (case side