X-Git-Url: http://uxul.de/gitweb/?a=blobdiff_plain;f=player.lisp;h=b3637675a6bf8e2dc1cff848c60d976bf787d3ec;hb=refs%2Fremotes%2Forigin%2FHEAD;hp=a111e43f9ed32606ef5f6c0d1cf0bb41c80c86b7;hpb=3520f2248cddebdc3c03a080047d76fdf1f6c382;p=uxul-world.git diff --git a/player.lisp b/player.lisp index a111e43..b363767 100755 --- a/player.lisp +++ b/player.lisp @@ -1,4 +1,4 @@ -;;; Copyright 2009 Christoph Senjak +;;; Copyright 2009-2011 Christoph Senjak (in-package :uxul-world) @@ -28,6 +28,12 @@ :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 @@ -69,10 +75,12 @@ :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 @@ -112,6 +120,12 @@ (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)))) @@ -153,6 +167,16 @@ (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)))