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)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue