diff options
-rw-r--r-- | examples/03-font-render.lisp | 25 | ||||
-rw-r--r-- | wheelwork.lisp | 2 |
2 files changed, 15 insertions, 12 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)) diff --git a/wheelwork.lisp b/wheelwork.lisp index 161f5b7..16eccad 100644 --- a/wheelwork.lisp +++ b/wheelwork.lisp @@ -643,7 +643,7 @@ ASSET-ARGS is a plist to pass to make-instance for the given resource. (defclass/std text (unit interactive) ((font :with :ri :std (error "A font is required") :type font) (content :with :ri :std "") - (color :with :ri :std #(1.0 1.0 1.0 1.0)) + (color :with :std #(1.0 1.0 1.0 1.0)) (vao elem-count :r) (shader :with :static :r))) |