summaryrefslogtreecommitdiff
path: root/bonnie-bee/common.scm
diff options
context:
space:
mode:
Diffstat (limited to 'bonnie-bee/common.scm')
-rw-r--r--bonnie-bee/common.scm27
1 files changed, 26 insertions, 1 deletions
diff --git a/bonnie-bee/common.scm b/bonnie-bee/common.scm
index 75a6bc4..885ab33 100644
--- a/bonnie-bee/common.scm
+++ b/bonnie-bee/common.scm
@@ -1,17 +1,22 @@
(define-module (bonnie-bee common)
+ #:use-module (bonnie-bee assets)
#:use-module (chickadee game-loop)
#:use-module (chickadee graphics color)
#:use-module (chickadee graphics viewport)
#:use-module (chickadee math vector)
+ #:use-module (chickadee scripting)
#:use-module (oop goops)
#:use-module (starling scene)
+ #:use-module (starling node)
#:use-module (starling node-2d)
#:export (%window-width
%window-height
%game-width
%game-height
set-cameras!
- steps))
+ steps
+ fade-in
+ fade-out))
(define %window-width 960)
(define %window-height 720)
@@ -27,3 +32,23 @@
(define (steps n)
(* n (current-timestep)))
+
+(define-method (fade-in (scene <scene-2d>) duration)
+ (let ((bg (make <sprite>
+ #:rank 999
+ #:texture darkness-image)))
+ (attach-to scene bg)
+ (tween duration 1.0 0.0
+ (lambda (a)
+ (set! (tint bg) (transparency a))))
+ (detach bg)))
+
+(define-method (fade-out (scene <scene-2d>) duration)
+ (let ((bg (make <sprite>
+ #:rank 999
+ #:texture darkness-image)))
+ (attach-to scene bg)
+ (tween duration 0.0 1.0
+ (lambda (a)
+ (set! (tint bg) (transparency a))))
+ (detach bg)))