diff options
author | Colin Okay <colin@cicadas.surf> | 2022-06-23 08:56:28 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-06-23 08:56:28 -0500 |
commit | 76d137475350287f6eddf7083ff0b7507a305e8c (patch) | |
tree | fea80ddf20419287d857ccd5495bad0717ca2236 /examples/02-moving-bitmp.lisp | |
parent | d9fba3559d77e96f145ab1fd968bce868074044e (diff) |
[add] eventhandling for mousedown and keyup
Diffstat (limited to 'examples/02-moving-bitmp.lisp')
-rw-r--r-- | examples/02-moving-bitmp.lisp | 28 |
1 files changed, 23 insertions, 5 deletions
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) + + |