diff options
author | Colin Okay <colin@cicadas.surf> | 2022-06-24 09:28:05 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-06-24 09:28:05 -0500 |
commit | 229a4caaa430ec5e20e9ad57ccb8c491c5ed653f (patch) | |
tree | cf44ef7eb4a4b841f1dce7ba92b65ec278a582c9 | |
parent | 129e6e79c27bff4f7f3cc07aa22028d7ede6f3bd (diff) |
[example] altering rotation on click
-rw-r--r-- | examples/02-moving-bitmp.lisp | 8 | ||||
-rw-r--r-- | wheelwork.lisp | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/examples/02-moving-bitmp.lisp b/examples/02-moving-bitmp.lisp index ca32b44..318bed4 100644 --- a/examples/02-moving-bitmp.lisp +++ b/examples/02-moving-bitmp.lisp @@ -63,6 +63,10 @@ (ww::on-mousedown () (format t "~a was clicked at ~a,~a!~%" target x y))) +(ww::defhandler flip-on-click + (ww::on-mousedown () + (incf (ww::unit-rotation target) (ww::radians 180) ))) + (ww::defhandler mouse-over (ww::on-mousemotion () (print (list target x y xrel yrel state)))) @@ -99,8 +103,8 @@ (setf (ww::unit-x bm2) 90 (ww::unit-y bm2) 90) (ww::set-handler bm2 #'move-thing) - (ww::set-handler bm2 #'thing-clicked) - (ww::set-handler bm2 #'look-at-me ) + (ww::set-handler bm2 #'flip-on-click ) + (ww::set-handler bm2 #'look-at-me) (ww::set-handler bm2 #'look-away) (ww::set-handler bm2 #'wheelie) (ww::add-unit app bm2))) diff --git a/wheelwork.lisp b/wheelwork.lisp index 6cebb66..8638c60 100644 --- a/wheelwork.lisp +++ b/wheelwork.lisp @@ -876,3 +876,11 @@ fires when the FOCUS slot of the current APPLICATION instance is changed. ,(intern (symbol-name target)))) ,@body))) +;;; Utility + +(define-symbol-macro +pi-over-180+ 0.017453292519943295d0) + +(defun radians (degrees) + "Converse DEGREES to radians" + (* degrees +pi-over-180+)) + |