aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/03-font-render.lisp
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-06-27 11:09:50 -0500
committerColin Okay <colin@cicadas.surf>2022-06-27 11:09:50 -0500
commit641d084e27f8178bd43784c292f4b6b482e64739 (patch)
tree8511a91022349a28a8639158b334c3d3c4699921 /examples/03-font-render.lisp
parent9c058339dde198062e96674c515ea946de5902b5 (diff)
[modify] renamed set-handler to add-handler
Diffstat (limited to 'examples/03-font-render.lisp')
-rw-r--r--examples/03-font-render.lisp25
1 files changed, 17 insertions, 8 deletions
diff --git a/examples/03-font-render.lisp b/examples/03-font-render.lisp
index e04d0c8..47ac9cb 100644
--- a/examples/03-font-render.lisp
+++ b/examples/03-font-render.lisp
@@ -1,18 +1,27 @@
-(defpackage #:ww.example/3
+(defpackage #:ww.examples/3
(:use :cl))
-(in-package #:ww.example/3)
+(in-package #:ww.examples/3)
(defclass font-display (ww::application) ())
+(define-symbol-macro +speed+ 2)
+
(ww::defhandler move-on-keydown
(ww::on-keydown ()
(case scancode
- (:scancode-up (incf (ww::unit-y target)))
- (:scancode-down (decf (ww::unit-y target)))
- (:scancode-left (decf (ww::unit-x target)))
- (:scancode-right (incf (ww::unit-x target))))))
+ (: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+)))))
+
+(ww::defhandler marquee
+ (ww::on-perframe ()
+ (when (< 800 (ww::unit-x target))
+ (setf (ww::unit-x target)
+ -800))
+ (incf (ww::unit-x target) +speed+)))
(defmethod ww::boot ((app font-display))
(let ((hello
@@ -31,8 +40,7 @@
(ww::unit-y hello) 100)
- (ww::set-handler hello #'move-on-keydown)
-
+ (ww::add-handler hello #'marquee)
(ww::refocus-on hello)
(ww::add-unit app hello)))
@@ -40,6 +48,7 @@
(defun start ()
(ww::start (make-instance 'font-display
+ :fps 60
:refocus-on-mousedown-p nil
:title "Wheelwork Example: Font display"
:asset-root "~/projects/wheelwork/examples/")))