From 99cbc4aaecb3879fb11791a20ed9c5d7246f4cfe Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Mon, 27 Jun 2022 12:26:21 -0500 Subject: [modify] text-color is an accessor now --- examples/03-font-render.lisp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'examples') diff --git a/examples/03-font-render.lisp b/examples/03-font-render.lisp index 47ac9cb..a854843 100644 --- a/examples/03-font-render.lisp +++ b/examples/03-font-render.lisp @@ -6,22 +6,23 @@ (defclass font-display (ww::application) ()) -(define-symbol-macro +speed+ 2) +(define-symbol-macro +speed+ 10) -(ww::defhandler move-on-keydown +(defun random-text-color () + (make-array 4 :initial-contents (list (random 1.0) (random 1.0) (random 1.0) 1.0))) + +(ww::defhandler change-text-color (ww::on-keydown () - (case scancode - (:scancode-up (incf (ww::unit-y target) +speed+)) - (:scancode-down (decf (ww::unit-y target) +speed+)) - (:scancode-left (decf (ww::unit-x target) +speed+)) - (:scancode-right (incf (ww::unit-x target) +speed+))))) + "Press any key to change the color of the text" + (format t "Pressed a key, changing the color~%") + (setf (ww::text-color target) (random-text-color)))) (ww::defhandler marquee (ww::on-perframe () - (when (< 800 (ww::unit-x target)) + (when (< 900 (ww::unit-x target)) (setf (ww::unit-x target) -800)) - (incf (ww::unit-x target) +speed+))) + (incf (ww::unit-x target) 5))) (defmethod ww::boot ((app font-display)) (let ((hello @@ -38,9 +39,10 @@ (ww::unit-x hello) 100 - (ww::unit-y hello) 100) + (ww::unit-y hello) 400) (ww::add-handler hello #'marquee) + (ww::add-handler hello #'change-text-color) (ww::refocus-on hello) (ww::add-unit app hello))) @@ -51,7 +53,8 @@ :fps 60 :refocus-on-mousedown-p nil :title "Wheelwork Example: Font display" - :asset-root "~/projects/wheelwork/examples/"))) + :asset-root "~/projects/wheelwork/examples/") + :x 2380)) -- cgit v1.2.3