From aa8a302fcb1e609a311151bc3c9b9bc22fc7a560 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 23 May 2024 12:06:42 -0400 Subject: [PATCH] Add simple wipe effect for undo. --- game.scm | 3 ++- modules/game/effects.scm | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/game.scm b/game.scm index 4bf4af7..3eaf110 100644 --- a/game.scm +++ b/game.scm @@ -108,7 +108,8 @@ ((snapshot . older-snapshots) (set! *actormap* snapshot) (set! *snapshots* older-snapshots) - (play-sound-effect audio:undo)))) + (play-sound-effect audio:undo) + (show-effect! (make-wipe-effect 0.25))))) (define (sort lst compare) (match lst diff --git a/modules/game/effects.scm b/modules/game/effects.scm index 29df590..62dca43 100644 --- a/modules/game/effects.scm +++ b/modules/game/effects.scm @@ -16,7 +16,8 @@ draw-effect make-fade-out+in-effect - make-screen-shake-effect)) + make-screen-shake-effect + make-wipe-effect)) (define (ease:smoothstep t) (* t t (- 3 (* 2 t)))) @@ -61,8 +62,8 @@ (define (make-fade-out+in-effect duration) (define (draw context t) (if (< t 0.5) - (set-global-alpha! context (pk 'alpha-out (* t 2.0))) - (set-global-alpha! context (pk 'alpha-in (- 1.0 (* (- t 0.5) 2.0))))) + (set-global-alpha! context (* t 2.0)) + (set-global-alpha! context (- 1.0 (* (- t 0.5) 2.0)))) (set-fill-color! context "#000000") (fill-rect context 0.0 0.0 game-width game-height) (set-global-alpha! context 1.0)) @@ -74,3 +75,9 @@ (y (round (random)))) (translate! context x y))) (make-effect 'pre duration draw)) + +(define (make-wipe-effect duration) + (define (draw context t) + (set-fill-color! context "#222034") + (fill-rect context 0.0 0.0 (* game-width (- 1.0 t)) game-height)) + (make-effect 'post duration draw))