From 76d137475350287f6eddf7083ff0b7507a305e8c Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Thu, 23 Jun 2022 08:56:28 -0500 Subject: [add] eventhandling for mousedown and keyup --- examples/02-moving-bitmp.lisp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'examples/02-moving-bitmp.lisp') diff --git a/examples/02-moving-bitmp.lisp b/examples/02-moving-bitmp.lisp index 425457b..4706d1b 100644 --- a/examples/02-moving-bitmp.lisp +++ b/examples/02-moving-bitmp.lisp @@ -21,21 +21,39 @@ (incf (ww::unit-width unit) 20.0))) (:scancode-minus (decf (ww::unit-height unit) 20.0) - (decf (ww::unit-width 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))) (defmethod ww::boot ((app bitmap-display)) (let ((bm (make-instance 'ww::bitmap - :texture (ww::get-asset "Fezghoul.png")))) + :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::add-unit app bm))) + (ww::set-handler bm #'thing-clicked ) + (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 3.0 + :scale 2.0 :asset-root #P"~/projects/wheelwork/examples/"))) -(start) + + -- cgit v1.2.3