Works again.
[uxul-world.git] / collision.lisp
1 ;;; Copyright 2009-2011 Christoph Senjak
2
3 (in-package :uxul-world)
4
5 (defclass collision ()
6   ((pos :initarg :pos
7         :accessor pos
8         :type xy-struct
9         :documentation "The position where the moving rectangle is at
10         the point of collision")
11    (direction :initarg :direction
12               :accessor direction
13               :documentation "On which side of the MOVING rectangle
14               does the collision occur?")
15    (collision-time :initarg :collision-time
16                    :accessor collision-time
17                    :type rational
18                    :documentation "The quotient of the length of the
19                    real movement and the length of the desired
20                    movement.")
21    (desired-movement :initarg :desired-movement
22                      :accessor desired-movement
23                      :type xy-struct
24                      :documentation "The full movement that was given
25    to move-about and could not be fulfilled.")))
26
27 (defmethod has-horizontal-direction ((obj collision))
28   "test, whether this has horizontal direction"
29   (or (eq (direction obj) :left)
30       (eq (direction obj) :right)))
31
32 (defmethod has-vertical-direction ((obj collision))
33   "test, whether this has vertical direction"
34   (or (eq (direction obj) :up)
35       (eq (direction obj) :down)))
36
37 (defmethod colliding ((object null))
38   nil)