(defpackage #:ww.examples/3 (:use #:cl) (:export #:start)) (in-package #:ww.examples/3) (defclass font-display (ww::application) ()) (define-symbol-macro +speed+ 10) (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 () "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)) (with-accessors ((x ww::unit-x) (y ww::unit-y) (w ww::unit-width) (h ww::unit-height)) target (format t "x:~a,y:~a,width:~a,height:~a~%" x y w h)))) (ww::defhandler marquee (ww::on-perframe () (when (< 900 (ww::unit-x target)) (setf (ww::unit-x target) -800)) (incf (ww::unit-x target) 5))) (defmethod ww::boot ((app font-display)) (let ((hello (make-instance 'ww::text :content "Hell! Oh World..." :font (ww::get-asset "Ticketing.ttf" :asset-args '(:oversample 2))))) (ww::set-height-preserve-aspect hello 100) (setf (ww::unit-x hello) 100 (ww::unit-y hello) 400) (ww::add-handler hello #'marquee) (ww::add-handler hello #'change-text-color) (ww::add-handler hello (ww::on-mousedown () (format t "I Was Clicked at ~a,~a!~%" x y))) (ww::refocus-on hello) (ww::add-unit app hello))) (defun start () (ww::start (make-instance 'font-display :fps 60 :refocus-on-mousedown-p nil :title "Wheelwork Example: Font display" :asset-root (merge-pathnames "examples/" (asdf:system-source-directory :wheelwork)))))