aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/03-font-render.lisp25
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))