From: christoph Date: Tue, 18 Aug 2009 23:28:55 +0000 (+0200) Subject: Bugfix. X-Git-Url: http://uxul.de/gitweb/?p=uxul-world.git;a=commitdiff_plain;h=b97da26f7129191eff0f3c90e831fd9e94e52a56 Bugfix. --- diff --git a/BUGS b/BUGS index e292a92..655148f 100644 --- a/BUGS +++ b/BUGS @@ -1,5 +1,8 @@ 2009/04/09 Setting the Animation of Jumping doesnt always work correct 2009/04/10 Random numeric type-errors + - 2009/08/19 Solved. The Problem were Objects that were drawn too + far away from the screen. Now I am clipping again, hopefully, this + time clipping works correctly. 2009/08/04 Jumping after falling down from a stone is possible diff --git a/draw.lisp b/draw.lisp index 03a40b8..1b058e6 100755 --- a/draw.lisp +++ b/draw.lisp @@ -46,7 +46,9 @@ )) (draw-background *current-translation-x* *current-translation-y*) (dolist (image (get-objects obj 'uxul-world::game-object)) - (if (and (redraw image) (visible image)) (draw image))))) + (if (and (redraw image) + (visible image) + (rectangle-in-screen image)) (draw image))))) ;; FIXME diff --git a/game-object-with-animation.lisp b/game-object-with-animation.lisp index 6b6aa13..993e72e 100755 --- a/game-object-with-animation.lisp +++ b/game-object-with-animation.lisp @@ -13,7 +13,17 @@ :documentation "The translation of the animation") (animation :initarg :animation :accessor animation - :documentation "The animation of this object"))) + :documentation "The animation of this object") + (animation-bounds :initarg :animation-bounds + :accessor animation-bounds + :initform (make-xy 50 50) + :documentation "When drawing, objects outside the + screen are tried not to be drawn via SDL. This determines, how far + in every direction the graphics may go outside the + collision-rectangle. Try to keep this number small. If it is too + huge, you may get numeric errors. 50/50 should be sufficient for + most objects. If this value is nil, the object will always be + drawn."))) (defmethod (setf animation) ((newval animation) (obj game-object-with-animation)) "Sets the animation and x and y-coordinates. Wont rewind the animation." @@ -35,16 +45,19 @@ (setf (visible (animation obj)) newval)) (defun rectangle-in-screen (obj) - (rectangles-overlap - ;; HAAAAAAAAAAAAAAACK - (- (x obj) 50) - (- (y obj) 50) - (+ (x obj) (width obj) 50) - (+ (y obj) (height obj) 50) - *current-translation-x* - *current-translation-y* - (- +screen-width+ *current-translation-x*) - (- +screen-height+ *current-translation-y*))) + (let ((bounds (animation-bounds obj))) + (if bounds + (rectangles-overlap + ;; HAAAAAAAAAAAAAAACK + (- (x obj) (x bounds)) + (- (y obj) (y bounds)) + (+ (x obj) (width obj) (x bounds)) + (+ (y obj) (height obj) (y bounds)) + (- *current-translation-x*) + (- *current-translation-y*) + (- +screen-width+ *current-translation-x*) + (- +screen-height+ *current-translation-y*)) + T)))