Add xor and level 4
This commit is contained in:
parent
dc05a9cd05
commit
a49808d70d
7 changed files with 93 additions and 3 deletions
|
@ -10,6 +10,7 @@
|
|||
^gate
|
||||
^gem
|
||||
^and-gate
|
||||
^xor-gate
|
||||
^electric-switch
|
||||
^player
|
||||
^level))
|
||||
|
@ -274,6 +275,46 @@
|
|||
(('describe) `(and-gate ,position))
|
||||
(('collide other offset grid-info) #f)))
|
||||
|
||||
(define (^xor-gate bcom x y)
|
||||
(define position (vector x y 0))
|
||||
(define state (spawn ^cell 'copper))
|
||||
(match-lambda*
|
||||
(('type) 'emitter)
|
||||
(('position) position)
|
||||
(('tick grid-info) #f)
|
||||
(('post-tick grid-info) #f)
|
||||
(('enter obj grid-info) #f)
|
||||
(('exit obj grid-info) #f)
|
||||
(('wire-state) ($ state))
|
||||
(('update-wire-state grid-info)
|
||||
(match ($ state)
|
||||
('electron-head ($ state 'electron-tail))
|
||||
('electron-tail ($ state 'copper))
|
||||
('copper
|
||||
;; TODO: Match other shapes? This only allows left-to-right
|
||||
;; circuit flow.
|
||||
(match (pk 'xor-grid-info ($ grid-info 'wireworld-neighbor-grid x y))
|
||||
(#('electron-head #f #f
|
||||
#f _ 'copper
|
||||
#f #f #f)
|
||||
($ state 'electron-head))
|
||||
(#('electron-head #f #f
|
||||
#f _ 'copper
|
||||
'copper #f #f)
|
||||
($ state 'electron-head))
|
||||
(#(#f #f #f
|
||||
#f _ 'copper
|
||||
'electron-head #f #f)
|
||||
($ state 'electron-head))
|
||||
(#('copper #f #f
|
||||
#f _ 'copper
|
||||
'electron-head #f #f)
|
||||
($ state 'electron-head))
|
||||
(_ ($ state 'copper))))))
|
||||
(('alive?) #t)
|
||||
(('describe) `(xor-gate ,position))
|
||||
(('collide other offset grid-info) #f)))
|
||||
|
||||
(define (^player bcom x y)
|
||||
(define position (spawn ^cell (vector x y 2)))
|
||||
(define velocity (spawn ^cell #(0 0)))
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
(12 (let ((target-x (bytevector-u8-ref objects (+ i 3)))
|
||||
(target-y (bytevector-u8-ref objects (+ i 4))))
|
||||
(spawn ^electric-switch x y target-x target-y)))
|
||||
(13 (spawn ^xor-gate x y))
|
||||
(id (error "invalid level object" id))))
|
||||
(i* (+ i (match id
|
||||
;; floor-switch or electric-switch
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.8" tiledversion="1.8.6" orientation="orthogonal" renderorder="right-down" width="20" height="15" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="22">
|
||||
<tileset firstgid="1" source="tiles.tsx"/>
|
||||
<layer id="1" name="background" width="20" height="15" visible="0">
|
||||
<layer id="1" name="background" width="20" height="15">
|
||||
<data encoding="csv">
|
||||
23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
|
||||
23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
|
||||
|
|
39
modules/game/levels/level-4.tmx
Normal file
39
modules/game/levels/level-4.tmx
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.8" tiledversion="1.8.6" orientation="orthogonal" renderorder="right-down" width="20" height="15" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="15">
|
||||
<tileset firstgid="1" source="tiles.tsx"/>
|
||||
<layer id="1" name="background" width="20" height="15">
|
||||
<data encoding="csv">
|
||||
23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
|
||||
23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
|
||||
23,23,24,24,24,24,24,24,24,24,24,24,24,24,23,23,23,23,23,23,
|
||||
23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,23,24,24,24,23,
|
||||
23,24,49,3,3,3,3,3,3,3,3,3,24,24,24,23,24,24,24,23,
|
||||
23,24,24,24,24,24,24,24,24,24,24,24,24,3,24,23,24,24,24,23,
|
||||
23,24,49,3,3,24,3,3,3,3,3,3,24,24,24,24,24,24,24,23,
|
||||
23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,23,24,24,24,23,
|
||||
23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,23,24,28,24,23,
|
||||
23,24,24,24,24,24,24,24,24,24,24,24,24,24,23,23,24,24,24,23,
|
||||
23,24,24,24,24,24,24,24,24,24,24,24,24,24,23,23,24,24,24,23,
|
||||
23,23,24,24,24,24,24,24,24,24,24,24,24,23,23,23,23,23,23,23,
|
||||
23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
|
||||
23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
|
||||
23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23
|
||||
</data>
|
||||
</layer>
|
||||
<objectgroup id="2" name="objects">
|
||||
<object id="1" type="player-spawn" gid="1" x="80" y="128" width="16" height="16"/>
|
||||
<object id="4" type="block" gid="4" x="80" y="96" width="16" height="16">
|
||||
<properties>
|
||||
<property name="kind" value="copper"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="8" type="electric-switch" gid="8" x="224" y="80" width="16" height="16">
|
||||
<properties>
|
||||
<property name="target-x" type="int" value="15"/>
|
||||
<property name="target-y" type="int" value="6"/>
|
||||
</properties>
|
||||
</object>
|
||||
<object id="9" type="gate" gid="46" x="240" y="96" width="16" height="16"/>
|
||||
<object id="13" type="xor-gate" gid="45" x="192" y="80" width="16" height="16"/>
|
||||
</objectgroup>
|
||||
</map>
|
Loading…
Add table
Add a link
Reference in a new issue