;;; 01-bitmap-display.lisp (defpackage #:ww.examples/2 (:use #:cl) (:export #:start)) (in-package :ww.examples/2) (defclass bitmap-display (ww::application ) ()) (ww::defhandler move-thing (ww::on-keydown (unit code mods) (case code (:scancode-left (decf (ww::unit-x unit) (ww::unit-width unit))) (:scancode-right (incf (ww::unit-x unit) (ww::unit-width unit))) (:scancode-down (decf (ww::unit-y unit) (ww::unit-height unit))) (:scancode-up (incf (ww::unit-y unit) (ww::unit-height unit))) (:scancode-equals (when (or (member :lshift mods) (member :rshift mods)) (incf (ww::unit-height unit) 20.0) (incf (ww::unit-width unit) 20.0))) (:scancode-minus (decf (ww::unit-height unit) 20.0) (decf (ww::unit-width unit) 20.0))) (format t "ghoul pos: ~a,~a~%" (ww::unit-x unit) (ww::unit-y unit)))) (ww::defhandler thing-clicked (ww::on-mousedown (unit x y clicks button) (format t "~a was clicked at ~a,~a!~%" unit x y))) (ww::defhandler mouse-over (ww::on-mousemotion (target x y xrel yrel state) (print (list target x y xrel yrel state)))) (defmethod ww::boot ((app bitmap-display)) (let ((bm (make-instance 'ww::bitmap :texture (ww::get-asset "Fezghoul.png"))) (bm2 (make-instance 'ww::bitmap :texture (ww::get-asset "RootBear.png")))) ;; first (ww::refocus-on bm) (ww::set-handler bm #'move-thing) (ww::set-handler bm #'thing-clicked) (ww::set-handler bm #'mouse-over) (ww::add-unit app bm) ;;second (setf (ww::unit-x bm2) 90 (ww::unit-y bm2) 90) (ww::set-handler bm2 #'move-thing) (ww::set-handler bm2 #'thing-clicked) (ww::add-unit app bm2))) (defun start () (ww::start (make-instance 'bitmap-display :scale 2.0 :asset-root #P"~/projects/wheelwork/examples/")))