Implement orientation for logic gates

Note that orientation is called "direction" because it's named according to the
direction of electron flow.
This commit is contained in:
Juliana Sims 2024-05-23 14:00:55 -04:00
parent 7803eaba1c
commit 73ffad19f0
5 changed files with 219 additions and 38 deletions

View file

@ -564,6 +564,11 @@ the default ORIENTATION value of 'orthogonal' is supported."
(define obj:or-gate 15)
(define obj:switched-emitter 16)
(define direction:right 1)
(define direction:left 2)
(define direction:up 3)
(define direction:down 4)
(define (compile-environment-layer tile-map layer-name)
(let ((tw (tile-map-tile-width tile-map))
(th (tile-map-tile-height tile-map))
@ -589,6 +594,12 @@ the default ORIENTATION value of 'orthogonal' is supported."
(iota (tile-layer-height layer)))))
(define (compile-object-layer tile-map layer-name)
(define parse-direction
(match-lambda
("right" direction:right)
("left" direction:left)
("up" direction:up)
("down" direction:down)))
(let ((tw (tile-map-tile-width tile-map))
(th (tile-map-tile-height tile-map))
(layer (tile-map-layer-ref tile-map layer-name)))
@ -610,9 +621,15 @@ the default ORIENTATION value of 'orthogonal' is supported."
(assq-ref properties 'target-y)))
('gem (list x y obj:gem))
('gate (list x y obj:gate))
('and-gate (list x y obj:and-gate))
('xor-gate (list x y obj:xor-gate))
('or-gate (list x y obj:or-gate))
('and-gate (list x y obj:and-gate
(parse-direction
(assq-ref properties 'direction))))
('xor-gate (list x y obj:xor-gate
(parse-direction
(assq-ref properties 'direction))))
('or-gate (list x y obj:or-gate
(parse-direction
(assq-ref properties 'direction))))
('electric-switch (list x y obj:electric-switch
(assq-ref properties 'target-x)
(assq-ref properties 'target-y)))