Combine ^gem and ^ghost-gem into one actor.

We still want the ghost gems to be collectable, even though they don't
do anything.
This commit is contained in:
David Thompson 2024-05-24 13:14:45 -04:00
parent e580454a97
commit 3503aeb00b
2 changed files with 8 additions and 22 deletions

View file

@ -12,7 +12,6 @@
^bomb ^bomb
^brick ^brick
^gem ^gem
^ghost-gem
^and-gate ^and-gate
^xor-gate ^xor-gate
^or-gate ^or-gate
@ -382,8 +381,9 @@
(('describe) `(bomb ,position ,($ exploding?))) (('describe) `(bomb ,position ,($ exploding?)))
(('collide other offset grid-info) #f))) (('collide other offset grid-info) #f)))
;; TODO: Combine with ghost gem. ;; A gem that has already been collected previously will still appear
(define (^gem bcom x y) ;; in the level but it will be drawn differently.
(define (^gem bcom x y previously-collected?)
(define position (vector x y 1)) (define position (vector x y 1))
(define picked-up? (spawn ^cell)) (define picked-up? (spawn ^cell))
(match-lambda* (match-lambda*
@ -396,27 +396,15 @@
(('wire-state grid-info from from-x from-y) #f) (('wire-state grid-info from from-x from-y) #f)
(('update-wire-state grid-info neighbor-grid) #f) (('update-wire-state grid-info neighbor-grid) #f)
(('alive?) (not ($ picked-up?))) (('alive?) (not ($ picked-up?)))
(('describe) `(gem ,position)) (('describe)
(if previously-collected?
`(ghost-gem ,position)
`(gem ,position)))
(('collide other offset grid-info) (('collide other offset grid-info)
(when (eq? ($ other 'type) 'player) (when (eq? ($ other 'type) 'player)
($ picked-up? #t) ($ picked-up? #t)
($ grid-info 'append-event `(pickup ,x ,y)))))) ($ grid-info 'append-event `(pickup ,x ,y))))))
(define (^ghost-gem bcom x y)
(define position (vector x y 1))
(match-lambda*
(('type) 'ghost-gem)
(('position) position)
(('tick grid-info) #f)
(('post-tick grid-info) #f)
(('enter obj grid-info) #f)
(('exit obj grid-info) #f)
(('wire-state grid-info from from-x from-y) #f)
(('update-wire-state grid-info neighbor-grid) #f)
(('alive?) #t)
(('describe) `(ghost-gem ,position))
(('collide other offset grid-info) #f)))
(define (^gate bcom x y) (define (^gate bcom x y)
(define position (vector x y 1)) (define position (vector x y 1))
(define open? (spawn ^cell)) (define open? (spawn ^cell))

View file

@ -77,9 +77,7 @@
(8 (let ((target-x (bytevector-u8-ref objects (+ i 3))) (8 (let ((target-x (bytevector-u8-ref objects (+ i 3)))
(target-y (bytevector-u8-ref objects (+ i 4)))) (target-y (bytevector-u8-ref objects (+ i 4))))
(spawn ^floor-switch x y target-x target-y))) (spawn ^floor-switch x y target-x target-y)))
(9 (if collected-gem? (9 (spawn ^gem x y collected-gem?))
(spawn ^ghost-gem x y)
(spawn ^gem x y)))
(10 (spawn ^gate x y)) (10 (spawn ^gate x y))
(11 (spawn ^and-gate x y (11 (spawn ^and-gate x y
(direction->symbol (direction->symbol