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