This repository has been archived by the owner on Jul 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jameson.lisp
55 lines (48 loc) · 1.91 KB
/
jameson.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(defvar *jameson-speed-x* 0) ; Variable that dictates how much Jameson's position along the x axis changes with each movement
(defvar *jameson-speed-y* 50) ; Variable that dictates how much Jameson's position along the y axis changes with each movement
;;; Class that defines the attributes of Jameson
(defclass jameson ()
((id
:initarg :id
:reader jameson-id)
(x
:initarg :x
:accessor jameson-x)
(y
:initarg :y
:accessor jameson-y)
(speed-x
:initarg :speed-x
:reader jameson-speed-x)
(speed-y
:initarg :speed-y
:reader jameson-speed-y))
(:default-initargs
:id "J"
:x 250
:y 150
:speed-x *jameson-speed-x*
:speed-y *jameson-speed-y*))
;; Method that moves Jameson up along the vertical axis
(defmethod move-jameson-up ((j jameson))
(setf (jameson-y j) (- (jameson-y j) (jameson-speed-y j))))
;; Method that moves Jameson down along the vertical axis
(defmethod move-jameson-down ((j jameson))
(setf (jameson-y j) (+ (jameson-y j) (jameson-speed-y j))))
;; Method that moves Jameson according to the decision taken by the ACT-R model
(defmethod move-jameson-on-decision ((j jameson) move-decision)
(cond ((equal move-decision "u") (move-jameson-up j))
((equal move-decision "d") (move-jameson-down j))
((equal move-decision "s") nil)))
;; Method that displays Jameson in the experiment's window
(defmethod present-jameson ((j jameson))
(add-text-to-exp-window :text (jameson-id j) :x (jameson-x j) :y (jameson-y j)))
;; Method that evaluates if, after the projectiles moved during the last timestep,
;; any projectile overlapped with Jameson's last position
(defmethod is-jameson-hit ((j jameson) projectiles)
(if (null projectiles)
nil
(if (and (= (jameson-x j) (projectile-x (first projectiles)))
(= (jameson-y j) (projectile-y (first projectiles))))
t
(is-jameson-hit j (rest projectiles)))))