From c88f91fd817d5e635b4a76b079bf47bdc7b7ec83 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Mon, 27 Jun 2022 17:30:56 -0500 Subject: [example] added twirl on click --- examples/02-moving-bitmp.lisp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/02-moving-bitmp.lisp b/examples/02-moving-bitmp.lisp index 3cc731a..0cce4e3 100644 --- a/examples/02-moving-bitmp.lisp +++ b/examples/02-moving-bitmp.lisp @@ -65,6 +65,22 @@ (ww::on-mousedown () (incf (ww::unit-rotation target) (ww::radians 180) ))) +(ww::defhandler twirl-on-click + (ww::on-mousedown () + (unless (gethash target *shared-anim-table*) + (let ((rot 0)) + (setf (gethash target *shared-anim-table*) t) + (ww::add-handler + target + (ww::on-perframe () + (if (< rot (* 8 pi)) + (setf rot (+ 0.3 rot) + (ww::unit-rotation target) rot) + (progn + (setf (ww::unit-rotation target) 0.0) + (ww::remove-handler target 'ww::perframe) + (remhash target *shared-anim-table*))))))))) + (ww::defhandler mouse-over (ww::on-mousemotion () (print (list target x y xrel yrel state)))) @@ -101,7 +117,7 @@ (setf (ww::unit-x bm2) 90 (ww::unit-y bm2) 90) (ww::add-handler bm2 #'move-thing) - (ww::add-handler bm2 #'flip-on-click ) + (ww::add-handler bm2 #'twirl-on-click ) (ww::add-handler bm2 #'look-at-me) (ww::add-handler bm2 #'look-away) (ww::add-handler bm2 #'wheelie) @@ -111,7 +127,7 @@ (defun start () (ww::start (make-instance 'bitmap-display :scale 2.0 - :fps 30 + :fps 60 :asset-root (merge-pathnames "examples/" (asdf:system-source-directory :wheelwork))))) -- cgit v1.2.3