)
(collide-blocks moving-rectangle standing-rectangle collision))
+(defmethod on-collision
+ ((moving-rectangle player)
+ (standing-rectangle door)
+ (collision collision))
+
+ (cond ((find (dungeon standing-rectangle) (keys moving-rectangle))
+ (setf (keys moving-rectangle) (delete (dungeon standing-rectangle) (keys moving-rectangle) :count 1))
+ (setf (visible standing-rectangle) nil)
+ (setf (active standing-rectangle) nil)
+ (setf (colliding standing-rectangle) nil))
+ ((eql (direction collision) :DOWN)
+ ;; "bottom" - allow jumping again
+ (setf (mayjump moving-rectangle) T))
+ ;; "ceiling" - dont allow continuing jump
+ ((eql (direction collision) :UP)
+ (setf (maycontjump moving-rectangle) nil)))
+ (collide-blocks moving-rectangle standing-rectangle collision))
+
+
(defmethod on-collision
((moving-rectangle player)
(standing-rectangle tulip)
:documentation "after hit by an enemy you wont be
wounded by another enemy for that ammount of
frames.")
- (keys :initform 0
+ (keys :initform nil
+ :initarg :keys
:accessor keys
- :documentation "Number of keys for doors")
- ))
+ :documentation "List of Key-Dungeons of keys (i.e. for every
+ key its key-dungeon is pushed on that list, for every door, its
+ removed again).") ))
;; Interaction with enemies
(class-name (class-of item))
(class-name (class-of player))))
+(defmethod item-catch ((item key) (player player) &rest args)
+ (declare (ignore args))
+ (push (dungeon item) (keys player))
+ (setf (visible item) nil)
+ (setf (colliding item) nil))
+
(defmethod (setf animation) ((new-value animation) (object player))
(setf (x new-value) (+ (x object) (x(animation-translation object))))
(setf (y new-value) (+ (y object) (y(animation-translation object))))
:initform 128)
(height :initarg :height
:accessor :height
- :initform 128)))
\ No newline at end of file
+ :initform 128)))
+
+(defclass key (standing-item)
+ ((animation :initarg :animation
+ :accessor animation
+ :initform (make-animation 0 |key|))
+ (width :initarg :width
+ :accessor width
+ :initform 128)
+ (height :initarg :height
+ :accessor height
+ :initform 128)
+ (dungeon :initarg :dungeon
+ :accessor dungeon
+ :initform nil
+ :documentation "To provide information in which rooms this key can be used.")))
+
+(defclass door (stone)
+ ((animation :initarg :animation
+ :accessor animation
+ :initform (make-animation 0 |door|))
+ (width :initarg :width
+ :accessor width
+ :initform 128)
+ (height :initarg :height
+ :accessor height
+ :initform 128)
+ (dungeon :initarg :dungeon
+ :accessor dungeon
+ :initform nil
+ :documentation "To provide information in which room this door is.")))
\ No newline at end of file
:visible t
:redraw t) ret)
+;;***************************
+ (add-object (make-instance 'key
+ :x (* 128 56)
+ :y (* 128 8)
+ :dungeon :testing-room
+ :visible t
+ :redraw t) ret)
+
(add-object (make-instance 'burning-marshmallow
:x (* 128 60)
(add-object (make-instance 'flying-nasobem
:x (* 128 87)
:y (* 128 2)) ret)
+ ;;*******************************
+ (add-object (make-instance 'door
+ :x (* 128 87)
+ :y (* 128 1)
+ :dungeon :testing-room
+ :visible t
+ :redraw t) ret)
+ (add-object (make-instance 'door
+ :x (* 128 89)
+ :y (* 128 1)
+ :dungeon :testing-room
+ :visible t
+ :redraw t) ret)
+
(add-object (make-instance 'flying-nasobem
:x (* 128 110)
:y (* 128 4)) ret)