1 ;;; Copyright 2009-2011 Christoph Senjak
3 (in-package :uxul-world)
5 (defclass simple-enemy (moving-enemy)
6 ((animation :initarg :animation
8 (make-animation 3 |nasobem| |nasobem2|)
10 (animation-translation :accessor animation-translation
11 :initarg :animation-translation
12 :initform (make-xy -100 -50))
13 (flat-animation :accessor flat-animation
14 :initform (make-animation 0 |nasobem3|))
15 (dont-ignore :accessor dont-ignore :initform t)
16 (activated :accessor activated :initform nil)
17 (width :initarg :width :initform 64 :accessor width)
18 (active :initarg :active :initform t :accessor active)
19 (height :initarg :height :initform 64 :accessor height)
20 (direction :initarg :direction :initform :left :accessor direction)))
22 (defmethod invoke ((obj simple-enemy))
23 "Move the object down-left if direction is :left"
25 ((activated obj) (move-about obj (make-xy
26 (if (eql (direction obj) :left)
30 (dolist (player (get-objects *current-room* 'player))
32 (< (abs (- (x player) (x obj))) (+ +screen-width+ 300))
33 (< (abs (- (y player) (y obj))) (+ +screen-height+ 300)))
34 (setf (activated obj) T))))))
36 (defun simple-enemy-and-player (player enemy)
37 (decf (power player)))
39 (defmethod player-hits-enemy ((player player) (enemy simple-enemy) &rest args)
41 ((eql (direction (car args)) :DOWN)
42 (setf (animation enemy) (flat-animation enemy))
43 (setf (active enemy) nil)
44 (setf (colliding enemy) nil)
45 (setf (listen-to player) (remove enemy (listen-to player))))
47 (simple-enemy-and-player player enemy))))
49 (defmethod enemy-hits-player ((enemy simple-enemy) (player player) &rest args)
50 (declare (ignore args))
51 (simple-enemy-and-player player enemy))