diff options
author | Colin Okay <colin@cicadas.surf> | 2022-06-27 17:30:56 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-06-27 17:30:56 -0500 |
commit | c88f91fd817d5e635b4a76b079bf47bdc7b7ec83 (patch) | |
tree | 1f7ce4e11c694e5ee786b0c237595f0f1d0911f3 /examples | |
parent | 04ceb7275ea341bef2b44dbcaa462b9ae90dac6f (diff) |
[example] added twirl on click
Diffstat (limited to 'examples')
-rw-r--r-- | examples/02-moving-bitmp.lisp | 20 |
1 files changed, 18 insertions, 2 deletions
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))))) |