Skip to content

Commit

Permalink
Basic guard sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Oct 6, 2019
1 parent 26a2936 commit 7468600
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
Binary file added data/guard.ase
Binary file not shown.
Binary file added data/guard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 11 additions & 9 deletions guard.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
(make-instance 'route-node :location location :delay delay))

(define-asset (ld45 guard-mesh) mesh
(make-rectangle 32 32))
(make-rectangle 64 64))

(define-global +guard-sway-aperture+ (->rad 45))
(define-global +guard-sway-aperture+ (->rad 30))
(define-global +guard-patrol-speed+ 64)
(define-global +guard-chase-speed+ 400)
(define-global +guard-scan-time+ 5)
Expand All @@ -27,7 +27,7 @@
(define-shader-subject guard (draggable solid animated-sprite-subject)
((vertex-array :initform (asset 'ld45 'guard-mesh))
(size :initform (vec 32 32))
(bsize :initform (vec 16 16))
(bsize :initform (vec 32 32))
(texture :initform (asset 'ld45 'guard))
(viewcone :initform (make-instance 'sector) :reader viewcone)
(state :initform :return)
Expand Down Expand Up @@ -68,9 +68,9 @@
(register-object-for-pass pass (viewcone guard)))

(defmethod paint :around ((guard guard) pass)
(call-next-method)
(unless (eql :down (state guard))
(paint (viewcone guard) pass)))
(paint (viewcone guard) pass))
(call-next-method))

(defmethod (setf route-index) :after (index (guard guard))
(when (and (/= 0 (length (route guard)))
Expand Down Expand Up @@ -133,10 +133,12 @@
(defmethod step :after ((guard guard) ev)
(setf (location (viewcone guard)) (location guard))
(case (state guard)
(:down (setf (animation guard) 'down))
(T (if (v/= 0 (velocity guard))
(setf (animation guard) 'walk)
(setf (animation guard) 'stand)))))
(:down
(setf (animation guard) 'down))
((:patrol :chase)
(setf (animation guard) 'walk))
(T
(setf (animation guard) 'stand))))

(defmethod down ((guard guard))
(unless (eql :down (state guard))
Expand Down
1 change: 1 addition & 0 deletions moving.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
(let ((d (dragger entity)))
(when d
(setf (location entity) (nv+ (nv* (angle-point (angle d)) (bsize entity) -2) (location d)))
(setf (angle entity) (- (angle d) PI))
(unless (eq :dragging (state d))
(setf (dragger entity) NIL)))))

Expand Down

0 comments on commit 7468600

Please sign in to comment.