diff options
Diffstat (limited to 'examples/07-renderarea.lisp')
-rw-r--r-- | examples/07-renderarea.lisp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/examples/07-renderarea.lisp b/examples/07-renderarea.lisp new file mode 100644 index 0000000..ead322f --- /dev/null +++ b/examples/07-renderarea.lisp @@ -0,0 +1,69 @@ +;;;; examples/07-scrollarea.lisp + +(defpackage #:ww.examples/7 + (:use #:cl) + (:export #:start)) + +(in-package #:ww.examples/7) + +(defclass scrollarea-example (ww::application) + ((cube :initarg :cube :accessor cube))) + +(ww::defhandler move-cube + (ww::on-keydown (app scancode) + (with-slots (cube) app + (case scancode + (:scancode-v + (setf (ww::unit-visiblep cube) + (not (ww::unit-visiblep cube)))) + (:scancode-left + (decf (ww::x cube) 15)) + (:scancode-right + (incf (ww::x cube) 15)) + (:scancode-up + (incf (ww::y cube) 15)) + (:scancode-down + (decf (ww::y cube) 15)))))) + +(ww::defhandler clicked + (ww::on-mousedown () + (format t "~a was clicked~%" target))) + +(defmethod ww::boot ((app scrollarea-example)) + (let ((cube + (make-instance + 'ww::bitmap + :texture (ww::get-asset "GelatinousCube.png"))) + (cube-container + (make-instance + 'ww::container + :bottom 200 :top 400 + :left 200 :right 600))) + + (setf (cube app) cube) + (ww::add-handler app #'move-cube) + (ww::add-handler cube #'clicked) + + + (setf (ww::x cube) 400 + (ww::y cube) 300) + + (ww::scale-by cube 2.0) + + (ww::add-unit cube-container cube) + (ww::add-unit app cube-container) + + (describe cube-container) + )) + + +(defun start () + (ww::start (make-instance + 'scrollarea-example + :fps 30 + :width 800 + :height 600 + :title "A scrollable area." + :asset-root (merge-pathnames + "examples/" + (asdf:system-source-directory :wheelwork))))) |