Tweak emitters so their wire state is more clear.
This has become a problem in the presence of bombs.
This commit is contained in:
parent
a102a9fb06
commit
892675f2d1
3 changed files with 36 additions and 28 deletions
18
game.scm
18
game.scm
|
@ -371,11 +371,17 @@
|
||||||
(define (draw-brick pos)
|
(define (draw-brick pos)
|
||||||
(draw-tile context tileset 22 (vec2-x pos) (vec2-y pos)))
|
(draw-tile context tileset 22 (vec2-x pos) (vec2-y pos)))
|
||||||
|
|
||||||
(define (draw-clock-emitter pos)
|
(define (draw-clock-emitter pos state)
|
||||||
(draw-tile context tileset 48 (vec2-x pos) (vec2-y pos)))
|
(draw-tile context tileset 48 (vec2-x pos) (vec2-y pos))
|
||||||
|
(set-global-alpha! context 0.5)
|
||||||
|
(draw-wire-state pos state)
|
||||||
|
(set-global-alpha! context 1.0))
|
||||||
|
|
||||||
(define (draw-switched-emitter pos on?)
|
(define (draw-switched-emitter pos state)
|
||||||
(draw-tile context tileset (if on? 48 47) (vec2-x pos) (vec2-y pos)))
|
(draw-tile context tileset (if state 48 47) (vec2-x pos) (vec2-y pos))
|
||||||
|
(set-global-alpha! context 0.5)
|
||||||
|
(draw-wire-state pos state)
|
||||||
|
(set-global-alpha! context 1.0))
|
||||||
|
|
||||||
(define (draw-floor-switch pos on?)
|
(define (draw-floor-switch pos on?)
|
||||||
(draw-tile context tileset (if on? 25 24) (vec2-x pos) (vec2-y pos)))
|
(draw-tile context tileset (if on? 25 24) (vec2-x pos) (vec2-y pos)))
|
||||||
|
@ -420,8 +426,8 @@
|
||||||
(('wall pos type) (draw-wall pos type))
|
(('wall pos type) (draw-wall pos type))
|
||||||
(('block pos type) (draw-block pos type))
|
(('block pos type) (draw-block pos type))
|
||||||
(('brick pos) (draw-brick pos))
|
(('brick pos) (draw-brick pos))
|
||||||
(('clock-emitter pos) (draw-clock-emitter pos))
|
(('clock-emitter pos state) (draw-clock-emitter pos state))
|
||||||
(('switched-emitter pos on?) (draw-switched-emitter pos on?))
|
(('switched-emitter pos state) (draw-switched-emitter pos state))
|
||||||
(('floor-switch pos on?) (draw-floor-switch pos on?))
|
(('floor-switch pos on?) (draw-floor-switch pos on?))
|
||||||
(('bomb pos countdown) (draw-bomb pos countdown))
|
(('bomb pos countdown) (draw-bomb pos countdown))
|
||||||
(('gem pos) (draw-gem pos))
|
(('gem pos) (draw-gem pos))
|
||||||
|
|
|
@ -165,43 +165,50 @@
|
||||||
(('pushed?) ($ pushed?))))
|
(('pushed?) ($ pushed?))))
|
||||||
|
|
||||||
(define (^clock-emitter bcom x y interval)
|
(define (^clock-emitter bcom x y interval)
|
||||||
(define timer (spawn ^cell -1))
|
(define timer (spawn ^cell 0))
|
||||||
(define position (vector x y 0))
|
(define position (vector x y 0))
|
||||||
|
(define (wire-state)
|
||||||
|
(match ($ timer)
|
||||||
|
(0 'electron-head)
|
||||||
|
(1 'electron-tail)
|
||||||
|
(_ 'copper)))
|
||||||
(match-lambda*
|
(match-lambda*
|
||||||
(('type) 'emitter)
|
(('type) 'emitter)
|
||||||
(('position) position)
|
(('position) position)
|
||||||
(('tick grid-info)
|
(('tick grid-info) #f)
|
||||||
|
(('post-tick grid-info)
|
||||||
(let ((t (modulo (+ ($ timer) 1) interval)))
|
(let ((t (modulo (+ ($ timer) 1) interval)))
|
||||||
($ timer t)
|
($ timer t)
|
||||||
(when (= t 0)
|
(when (= t 1)
|
||||||
($ grid-info 'append-event `(emit ,x ,y)))))
|
($ grid-info 'append-event `(emit ,x ,y)))))
|
||||||
(('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)
|
||||||
(('wire-state grid-info from from-x from-y)
|
(('wire-state grid-info from from-x from-y) (wire-state))
|
||||||
(match ($ timer)
|
|
||||||
(0 'electron-head)
|
|
||||||
(1 'electron-tail)
|
|
||||||
(_ 'copper)))
|
|
||||||
(('update-wire-state grid-info neighbor-grid) #f)
|
(('update-wire-state grid-info neighbor-grid) #f)
|
||||||
(('alive?) #t)
|
(('alive?) #t)
|
||||||
(('describe) `(clock-emitter ,position))
|
(('describe) `(clock-emitter ,position ,(wire-state)))
|
||||||
(('collide other offset grid-info) #f)))
|
(('collide other offset grid-info) #f)))
|
||||||
|
|
||||||
(define (^switched-emitter bcom x y interval)
|
(define (^switched-emitter bcom x y interval)
|
||||||
(define timer (spawn ^cell -1))
|
(define timer (spawn ^cell 0))
|
||||||
(define on? (spawn ^cell))
|
(define on? (spawn ^cell))
|
||||||
(define position (vector x y 0))
|
(define position (vector x y 0))
|
||||||
|
(define (wire-state)
|
||||||
|
(and ($ on?)
|
||||||
|
(match ($ timer)
|
||||||
|
(0 'electron-head)
|
||||||
|
(1 'electron-tail)
|
||||||
|
(_ 'copper))))
|
||||||
(match-lambda*
|
(match-lambda*
|
||||||
(('type) 'switched-emitter)
|
(('type) 'switched-emitter)
|
||||||
(('position) position)
|
(('position) position)
|
||||||
(('tick grid-info)
|
(('tick grid-info) #f)
|
||||||
|
(('post-tick grid-info)
|
||||||
(when ($ on?)
|
(when ($ on?)
|
||||||
(let ((t (modulo (+ ($ timer) 1) interval)))
|
(let ((t (modulo (+ ($ timer) 1) interval)))
|
||||||
($ timer t)
|
($ timer t)
|
||||||
(when (= t 0)
|
(when (= t 1)
|
||||||
($ grid-info 'append-event `(emit ,x ,y))))))
|
($ grid-info 'append-event `(emit ,x ,y))))))
|
||||||
(('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)
|
||||||
(('activate grid-info)
|
(('activate grid-info)
|
||||||
|
@ -211,16 +218,11 @@
|
||||||
(('deactivate grid-info)
|
(('deactivate grid-info)
|
||||||
($ on? #f)
|
($ on? #f)
|
||||||
($ grid-info 'append-event `(emitter-off ,x ,y)))
|
($ grid-info 'append-event `(emitter-off ,x ,y)))
|
||||||
(('wire-state grid-info from from-x from-y)
|
(('wire-state grid-info from from-x from-y) (wire-state))
|
||||||
(and ($ on?)
|
|
||||||
(match ($ timer)
|
|
||||||
(0 'electron-head)
|
|
||||||
(1 'electron-tail)
|
|
||||||
(_ 'copper))))
|
|
||||||
(('update-wire-state grid-info neighbor-grid) #f)
|
(('update-wire-state grid-info neighbor-grid) #f)
|
||||||
(('alive?) #t)
|
(('alive?) #t)
|
||||||
(('on?) ($ on?))
|
(('on?) ($ on?))
|
||||||
(('describe) `(switched-emitter ,position ,($ on?)))
|
(('describe) `(switched-emitter ,position ,(wire-state)))
|
||||||
(('collide other offset grid-info) #f)))
|
(('collide other offset grid-info) #f)))
|
||||||
|
|
||||||
(define (first-non-player-occupant grid-info x y)
|
(define (first-non-player-occupant grid-info x y)
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
</object>
|
</object>
|
||||||
<object id="22" type="clock-emitter" gid="49" x="32" y="144" width="16" height="16">
|
<object id="22" type="clock-emitter" gid="49" x="32" y="144" width="16" height="16">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="interval" type="int" value="1"/>
|
<property name="interval" type="int" value="3"/>
|
||||||
</properties>
|
</properties>
|
||||||
</object>
|
</object>
|
||||||
<object id="23" type="switched-emitter" gid="48" x="80" y="112" width="16" height="16">
|
<object id="23" type="switched-emitter" gid="48" x="80" y="112" width="16" height="16">
|
||||||
|
|
Loading…
Add table
Reference in a new issue