Removed some boilerplate.
[uxul-world.git] / player.lisp
index a111e43..b363767 100755 (executable)
@@ -1,4 +1,4 @@
-;;; Copyright 2009 Christoph Senjak
+;;; Copyright 2009-2011 Christoph Senjak
 
 (in-package :uxul-world)
 
              :initform  (make-animation 7
                                        |uxul_small1|
                                        |uxul_small2|))
+   (last-y :initarg :last-pos
+            :accessor last-y
+            :initform nil)
+   (bounced :initarg :bounced
+           :accessor bounced
+           :initform nil)
    (jump-accel :accessor jump-accel
               :initform -50)
    (mayjump :accessor mayjump
               :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))))
 (defmethod invoke ((obj player))
   "Do whatever a player does ^^"
 
+  (cond
+    ((bounced obj)
+     (setf (bounced obj) nil))
+    ((and
+      (last-y obj)
+      (< (last-y obj) (y obj)))
+     (setf (mayjump obj) nil)))
+
+  (setf (last-y obj) (y obj))
+
   ;; SIMPLE GRAVITY HACK
   (setf (key-pressed-down obj) (not (key-pressed-up obj)))