aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-07-06 09:37:47 -0500
committerColin Okay <colin@cicadas.surf>2022-07-06 09:37:47 -0500
commit827dadbc91abdb8e2143c2a15b996e0e5ad87fc6 (patch)
tree9389580fa8a4b6d5fea6afac0ed7ffefbda53b00 /examples
parentfda1d9d08349dfe103b7af3ef8f305c1701933f6 (diff)
[add] renderarea example
Diffstat (limited to 'examples')
-rw-r--r--examples/07-renderarea.lisp69
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)))))