]> git.jsancho.org Git - gacela.git/blobdiff - examples/02-event-driven-programming/02-event-driven-programming.scm
Customizing quit event behaviour
[gacela.git] / examples / 02-event-driven-programming / 02-event-driven-programming.scm
index 2fcd3ababc46925c9ad0f78d8b1a4c0860ee4ef1..b15123368cbafcdf90ae2a4f47761976a673db88 100644 (file)
 
 (use-modules (gacela))
 
+(define counter-quit #f)
+(let ((n 0))
+  (set! counter-quit
+    (lambda ()
+      (set! n (+ n 1))
+      (format #t "Quit clicked ~a times !!~%" n)
+      (if (> n 2)
+         (stop-game)))))
+
 (display-scene
- (window '(#:resolution (640 480))
-        (bitmap "x.bmp")))
+ (window ((resolution '(640 480))
+         (when-quit counter-quit))
+   (bitmap "x.bmp")))