Tweak warp actor; adjust tutorial-7.
This commit is contained in:
parent
770a5e6b7d
commit
551e85266e
2 changed files with 8 additions and 6 deletions
|
@ -305,7 +305,7 @@
|
||||||
(define (^electron-warp bcom x y target-x target-y)
|
(define (^electron-warp bcom x y target-x target-y)
|
||||||
(define position (vector x y 0))
|
(define position (vector x y 0))
|
||||||
(define state (spawn ^cell 'copper))
|
(define state (spawn ^cell 'copper))
|
||||||
(define electron? (spawn ^cell))
|
(define warp-state (spawn ^cell 'waiting))
|
||||||
(define (find-receiver grid-info)
|
(define (find-receiver grid-info)
|
||||||
(let lp ((objs ($ grid-info 'occupants target-x target-y)))
|
(let lp ((objs ($ grid-info 'occupants target-x target-y)))
|
||||||
(match objs
|
(match objs
|
||||||
|
@ -317,7 +317,9 @@
|
||||||
(match-lambda*
|
(match-lambda*
|
||||||
(('type) 'electron-warp)
|
(('type) 'electron-warp)
|
||||||
(('position) position)
|
(('position) position)
|
||||||
(('tick grid-info) #f)
|
(('tick grid-info)
|
||||||
|
(when (eq? ($ warp-state) 'receiving)
|
||||||
|
($ warp-state 'received)))
|
||||||
(('post-tick grid-info) #f)
|
(('post-tick grid-info) #f)
|
||||||
(('enter obj grid-info) #f)
|
(('enter obj grid-info) #f)
|
||||||
(('exit obj grid-info) #f)
|
(('exit obj grid-info) #f)
|
||||||
|
@ -327,10 +329,10 @@
|
||||||
('electron-head ($ state 'electron-tail))
|
('electron-head ($ state 'electron-tail))
|
||||||
('electron-tail ($ state 'copper))
|
('electron-tail ($ state 'copper))
|
||||||
('copper
|
('copper
|
||||||
(if ($ electron?)
|
(if (eq? ($ warp-state) 'received)
|
||||||
(begin
|
(begin
|
||||||
($ state 'electron-head)
|
($ state 'electron-head)
|
||||||
($ electron? #f)
|
($ warp-state 'waiting)
|
||||||
($ grid-info 'append-event `(receive-electron ,x ,y)))
|
($ grid-info 'append-event `(receive-electron ,x ,y)))
|
||||||
(let ((neighbors (electron-head-count neighbor-grid)))
|
(let ((neighbors (electron-head-count neighbor-grid)))
|
||||||
(if (<= 1 neighbors 2)
|
(if (<= 1 neighbors 2)
|
||||||
|
@ -340,7 +342,7 @@
|
||||||
($ (find-receiver grid-info) 'give-electron)
|
($ (find-receiver grid-info) 'give-electron)
|
||||||
($ grid-info 'append-event `(send-electron ,x ,y)))
|
($ grid-info 'append-event `(send-electron ,x ,y)))
|
||||||
($ state 'copper)))))))
|
($ state 'copper)))))))
|
||||||
(('give-electron) ($ electron? #t))
|
(('give-electron) ($ warp-state 'receiving))
|
||||||
(('alive?) #t)
|
(('alive?) #t)
|
||||||
(('describe) `(electron-warp ,position ,($ state)))
|
(('describe) `(electron-warp ,position ,($ state)))
|
||||||
(('collide other offset grid-info) #f)))
|
(('collide other offset grid-info) #f)))
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</data>
|
</data>
|
||||||
</layer>
|
</layer>
|
||||||
<objectgroup id="2" name="objects">
|
<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="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">
|
<object id="28" type="electric-switch" gid="8" x="80" y="128" width="16" height="16">
|
||||||
<properties>
|
<properties>
|
||||||
|
|
Loading…
Add table
Reference in a new issue