aboutsummaryrefslogtreecommitdiffhomepage
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
parentfda1d9d08349dfe103b7af3ef8f305c1701933f6 (diff)
[add] renderarea example
-rw-r--r--examples/07-renderarea.lisp69
-rw-r--r--wheelwork-examples.asd3
2 files changed, 71 insertions, 1 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)))))
diff --git a/wheelwork-examples.asd b/wheelwork-examples.asd
index d2515ed..a5a5498 100644
--- a/wheelwork-examples.asd
+++ b/wheelwork-examples.asd
@@ -11,4 +11,5 @@
(:file "03-font-render")
(:file "04-a-button")
(:file "05-frameset-animation")
- (:file "06-sprite")))
+ (:file "06-sprite")
+ (:file "07-renderarea")))