summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-10-28 15:08:57 -0400
committerDavid Thompson <dthompson2@worcester.edu>2023-10-28 15:09:09 -0400
commite48620fc1b5a8ba4d8a3b58963750a3af85f1242 (patch)
tree241b752b28dae735576eff2d795db076c975d81c
parent4326efa58fa6a716f3bd7664f60f9301510edfc2 (diff)
Fix scroll speed transitions.
-rw-r--r--game.scm37
-rw-r--r--level.tmx106
2 files changed, 73 insertions, 70 deletions
diff --git a/game.scm b/game.scm
index 7b93efa..296dc3a 100644
--- a/game.scm
+++ b/game.scm
@@ -432,13 +432,14 @@
body ...
(loop)))
(define* (tween proc duration start end ease interpolate)
- (let loop ((t 0))
- (if (= t duration)
- (proc end)
- (let ((alpha (ease (/ t duration))))
- (proc (interpolate start end alpha))
- (wait 1)
- (loop (+ t 1))))))
+ (let ((d (inexact duration)))
+ (let loop ((t 0))
+ (if (= t duration)
+ (proc end)
+ (let ((alpha (ease (/ (inexact t) d))))
+ (proc (interpolate start end alpha))
+ (wait 1)
+ (loop (+ t 1)))))))
;; Particles:
(define-type particle-pool
@@ -634,11 +635,13 @@
(define *last-scroll* 0.0)
(define *scroll-speed* 0.5)
(define (change-scroll-speed new-speed duration)
- (tween (lambda (speed)
- (set! *scroll-speed* speed))
- duration
- *scroll-speed* new-speed
- smoothstep lerp))
+ (run-script
+ (lambda ()
+ (tween (lambda (speed)
+ (set! *scroll-speed* speed))
+ duration
+ *scroll-speed* new-speed
+ smoothstep lerp))))
(define *last-row-scanned* 0)
;; action id, sprite sheet offset, x, y
(define %tile-size (+ 4 8 8 8))
@@ -721,9 +724,9 @@
('boss (spawn-boss x y))
('scroll-speed
(let ((speed (assq-ref properties 'speed))
- (ticks (or (assq-ref properties 'ticks) 0)))
+ (duration (or (assq-ref properties 'duration) 0)))
(when speed
- (change-scroll-speed speed ticks))))
+ (change-scroll-speed speed duration))))
(_ #t)))
(define max-scroll (- (* (level-height level) tile-height) game-height))
(define (level-update! level)
@@ -1105,9 +1108,9 @@
(if (or (rect-collides-with-level? level x y hbw hbh)
(find-enemy enemies x y hbw hbh))
(begin
- (set-vec2-x! player-position old-x)
- (set-vec2-y! player-position
- (+ old-y (- *scroll* *last-scroll*)))
+ ;; (set-vec2-x! player-position old-x)
+ ;; (set-vec2-y! player-position
+ ;; (+ old-y (- *scroll* *last-scroll*)))
(player-die!))
(begin
(set-vec2-x! player-hitbox-position (- x (/ hbw 2.0)))
diff --git a/level.tmx b/level.tmx
index a3e93c4..4b0ab00 100644
--- a/level.tmx
+++ b/level.tmx
@@ -75,29 +75,29 @@
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,
-1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,
-1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,
-1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,
-1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,
-1,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6,6,6,
+6,6,6,6,6,6,6,6,6,6,0,6,6,6,6,
+6,6,6,6,6,6,6,6,6,6,0,6,6,6,6,
+6,6,6,6,6,6,6,6,6,0,0,0,6,6,6,
+6,6,6,6,6,6,6,6,6,0,0,0,6,6,6,
+6,6,6,6,6,6,6,6,6,0,0,0,6,6,6,
+6,6,6,6,6,6,6,6,6,0,0,0,6,6,6,
+6,6,6,6,6,6,6,6,6,0,0,0,6,6,6,
+6,6,6,6,6,6,6,6,6,0,0,0,6,6,6,
+6,6,6,6,6,6,6,6,6,0,0,0,6,6,6,
+6,6,6,6,6,6,6,6,6,0,0,0,6,6,6,
+6,6,6,6,6,6,6,6,6,0,0,0,6,6,6,
+6,6,6,6,6,6,6,6,6,0,0,0,6,6,6,
+6,6,6,6,0,0,0,0,0,0,0,0,6,6,6,
+6,6,6,6,0,0,0,0,0,0,0,0,6,6,6,
+6,6,6,6,0,0,0,0,0,0,0,0,6,6,6,
6,6,6,6,0,0,0,6,6,6,6,6,6,6,6,
6,6,6,6,0,0,0,6,6,6,6,6,6,6,6,
6,6,6,6,0,0,0,6,6,6,6,6,6,6,6,
@@ -1051,7 +1051,7 @@
<object id="71" type="scroll-speed" x="0" y="4992" width="16" height="16">
<properties>
<property name="duration" type="int" value="30"/>
- <property name="speed" type="float" value="0.25"/>
+ <property name="speed" type="float" value="0.4"/>
</properties>
</object>
<object id="72" type="scroll-speed" x="0" y="7984" width="16" height="16">
@@ -1155,9 +1155,9 @@
<property name="speed" type="float" value="0"/>
</properties>
</object>
- <object id="164" type="scroll-speed" x="0" y="2704" width="16" height="16">
+ <object id="164" type="scroll-speed" x="0" y="2512" width="16" height="16">
<properties>
- <property name="duration" type="int" value="60"/>
+ <property name="duration" type="int" value="120"/>
<property name="speed" type="float" value="0.5"/>
</properties>
</object>
@@ -1167,13 +1167,13 @@
<property name="speed" type="float" value="2"/>
</properties>
</object>
- <object id="166" type="scroll-speed" x="0" y="784" width="16" height="16">
+ <object id="166" type="scroll-speed" x="0" y="736" width="16" height="16">
<properties>
<property name="duration" type="int" value="120"/>
- <property name="speed" type="float" value="0.5"/>
+ <property name="speed" type="float" value="0.25"/>
</properties>
</object>
- <object id="167" type="scroll-speed" x="0" y="640" width="16" height="16">
+ <object id="167" type="scroll-speed" x="0" y="400" width="16" height="16">
<properties>
<property name="duration" type="int" value="30"/>
<property name="speed" type="float" value="0.5"/>
@@ -1182,7 +1182,7 @@
<object id="169" type="scroll-speed" x="0" y="3824" width="16" height="16">
<properties>
<property name="duration" type="int" value="60"/>
- <property name="speed" type="float" value="1.5"/>
+ <property name="speed" type="float" value="2"/>
</properties>
</object>
</objectgroup>