From 551e85266e65118b06a32ecdfc0966c021605d57 Mon Sep 17 00:00:00 2001
From: David Thompson <dthompson2@worcester.edu>
Date: Sat, 25 May 2024 09:01:04 -0400
Subject: [PATCH] Tweak warp actor; adjust tutorial-7.

---
 modules/game/actors.scm            | 12 +++++++-----
 modules/game/levels/tutorial-7.tmx |  2 +-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/modules/game/actors.scm b/modules/game/actors.scm
index 730ec55..ba06c40 100644
--- a/modules/game/actors.scm
+++ b/modules/game/actors.scm
@@ -305,7 +305,7 @@
 (define (^electron-warp bcom x y target-x target-y)
   (define position (vector x y 0))
   (define state (spawn ^cell 'copper))
-  (define electron? (spawn ^cell))
+  (define warp-state (spawn ^cell 'waiting))
   (define (find-receiver grid-info)
     (let lp ((objs ($ grid-info 'occupants target-x target-y)))
       (match objs
@@ -317,7 +317,9 @@
   (match-lambda*
     (('type) 'electron-warp)
     (('position) position)
-    (('tick grid-info) #f)
+    (('tick grid-info)
+     (when (eq? ($ warp-state) 'receiving)
+       ($ warp-state 'received)))
     (('post-tick grid-info) #f)
     (('enter obj grid-info) #f)
     (('exit obj grid-info) #f)
@@ -327,10 +329,10 @@
        ('electron-head ($ state 'electron-tail))
        ('electron-tail ($ state 'copper))
        ('copper
-        (if ($ electron?)
+        (if (eq? ($ warp-state) 'received)
             (begin
               ($ state 'electron-head)
-              ($ electron? #f)
+              ($ warp-state 'waiting)
               ($ grid-info 'append-event `(receive-electron ,x ,y)))
             (let ((neighbors (electron-head-count neighbor-grid)))
               (if (<= 1 neighbors 2)
@@ -340,7 +342,7 @@
                     ($ (find-receiver grid-info) 'give-electron)
                     ($ grid-info 'append-event `(send-electron ,x ,y)))
                   ($ state 'copper)))))))
-    (('give-electron) ($ electron? #t))
+    (('give-electron) ($ warp-state 'receiving))
     (('alive?) #t)
     (('describe) `(electron-warp ,position ,($ state)))
     (('collide other offset grid-info) #f)))
diff --git a/modules/game/levels/tutorial-7.tmx b/modules/game/levels/tutorial-7.tmx
index 96add2f..8f95938 100644
--- a/modules/game/levels/tutorial-7.tmx
+++ b/modules/game/levels/tutorial-7.tmx
@@ -21,7 +21,7 @@
 </data>
  </layer>
  <objectgroup id="2" name="objects">
-  <object id="1" type="player-spawn" gid="1" x="192" y="112" width="16" height="16"/>
+  <object id="1" type="player-spawn" gid="1" x="192" y="96" width="16" height="16"/>
   <object id="7" type="gem" gid="29" x="288" y="96" width="16" height="16"/>
   <object id="28" type="electric-switch" gid="8" x="80" y="128" width="16" height="16">
    <properties>