diff options
author | Colin Okay <colin@cicadas.surf> | 2022-06-27 12:26:21 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-06-27 12:26:21 -0500 |
commit | 99cbc4aaecb3879fb11791a20ed9c5d7246f4cfe (patch) | |
tree | 1f9bbd2c2b4d479c9186f5f430e65e8778fc48f0 /examples/03-font-render.lisp | |
parent | 641d084e27f8178bd43784c292f4b6b482e64739 (diff) |
[modify] text-color is an accessor now
Diffstat (limited to 'examples/03-font-render.lisp')
-rw-r--r-- | examples/03-font-render.lisp | 25 |
1 files changed, 14 insertions, 11 deletions
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)) |