aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/03-font-render.lisp23
1 files changed, 19 insertions, 4 deletions
diff --git a/examples/03-font-render.lisp b/examples/03-font-render.lisp
index e47341b..60ffcf2 100644
--- a/examples/03-font-render.lisp
+++ b/examples/03-font-render.lisp
@@ -26,6 +26,24 @@
-800))
(incf (ww::unit-x target) 5)))
+(defvar *spin-table* (make-hash-table :synchronized t))
+
+(ww::defhandler spin
+ (ww::on-perframe ()
+ (let ((rot
+ (gethash target *spin-table* 0.0)))
+ (if (< rot (* 8 pi))
+ (setf
+ (gethash target *spin-table*) (+ rot 0.2)
+ (ww::unit-rotation target) rot)
+ (progn
+ (ww::remove-handler target #'spin)
+ (remhash target *spin-table*))))))
+
+(ww::defhandler twirl-on-click
+ (ww::on-mousedown ()
+ (ww::add-handler target #'spin)))
+
(defmethod ww::boot ((app font-display))
(let ((hello
(make-instance
@@ -39,10 +57,7 @@
(ww::unit-y hello) 400)
(ww::add-handler hello #'marquee)
(ww::add-handler hello #'change-text-color)
- (ww::add-handler hello
- (ww::on-mousedown ()
- (format t "I Was Clicked at ~a,~a!~%"
- x y)))
+ (ww::add-handler hello #'twirl-on-click)
(ww::refocus-on hello)
(ww::add-unit app hello)))