diff --git a/game.scm b/game.scm
index 6359e17..46bc2ac 100644
--- a/game.scm
+++ b/game.scm
@@ -371,11 +371,17 @@
(define (draw-brick pos)
(draw-tile context tileset 22 (vec2-x pos) (vec2-y pos)))
-(define (draw-clock-emitter pos)
- (draw-tile context tileset 48 (vec2-x pos) (vec2-y pos)))
+(define (draw-clock-emitter pos state)
+ (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?)
- (draw-tile context tileset (if on? 48 47) (vec2-x pos) (vec2-y pos)))
+(define (draw-switched-emitter pos state)
+ (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?)
(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))
(('block pos type) (draw-block pos type))
(('brick pos) (draw-brick pos))
- (('clock-emitter pos) (draw-clock-emitter pos))
- (('switched-emitter pos on?) (draw-switched-emitter pos on?))
+ (('clock-emitter pos state) (draw-clock-emitter pos state))
+ (('switched-emitter pos state) (draw-switched-emitter pos state))
(('floor-switch pos on?) (draw-floor-switch pos on?))
(('bomb pos countdown) (draw-bomb pos countdown))
(('gem pos) (draw-gem pos))
diff --git a/modules/game/actors.scm b/modules/game/actors.scm
index 1ce6d61..0f2ff60 100644
--- a/modules/game/actors.scm
+++ b/modules/game/actors.scm
@@ -165,43 +165,50 @@
(('pushed?) ($ pushed?))))
(define (^clock-emitter bcom x y interval)
- (define timer (spawn ^cell -1))
+ (define timer (spawn ^cell 0))
(define position (vector x y 0))
+ (define (wire-state)
+ (match ($ timer)
+ (0 'electron-head)
+ (1 'electron-tail)
+ (_ 'copper)))
(match-lambda*
(('type) 'emitter)
(('position) position)
- (('tick grid-info)
+ (('tick grid-info) #f)
+ (('post-tick grid-info)
(let ((t (modulo (+ ($ timer) 1) interval)))
($ timer t)
- (when (= t 0)
+ (when (= t 1)
($ grid-info 'append-event `(emit ,x ,y)))))
- (('post-tick grid-info) #f)
(('enter obj grid-info) #f)
(('exit obj grid-info) #f)
- (('wire-state grid-info from from-x from-y)
- (match ($ timer)
- (0 'electron-head)
- (1 'electron-tail)
- (_ 'copper)))
+ (('wire-state grid-info from from-x from-y) (wire-state))
(('update-wire-state grid-info neighbor-grid) #f)
(('alive?) #t)
- (('describe) `(clock-emitter ,position))
+ (('describe) `(clock-emitter ,position ,(wire-state)))
(('collide other offset grid-info) #f)))
(define (^switched-emitter bcom x y interval)
- (define timer (spawn ^cell -1))
+ (define timer (spawn ^cell 0))
(define on? (spawn ^cell))
(define position (vector x y 0))
+ (define (wire-state)
+ (and ($ on?)
+ (match ($ timer)
+ (0 'electron-head)
+ (1 'electron-tail)
+ (_ 'copper))))
(match-lambda*
(('type) 'switched-emitter)
(('position) position)
- (('tick grid-info)
+ (('tick grid-info) #f)
+ (('post-tick grid-info)
(when ($ on?)
(let ((t (modulo (+ ($ timer) 1) interval)))
($ timer t)
- (when (= t 0)
+ (when (= t 1)
($ grid-info 'append-event `(emit ,x ,y))))))
- (('post-tick grid-info) #f)
(('enter obj grid-info) #f)
(('exit obj grid-info) #f)
(('activate grid-info)
@@ -211,16 +218,11 @@
(('deactivate grid-info)
($ on? #f)
($ grid-info 'append-event `(emitter-off ,x ,y)))
- (('wire-state grid-info from from-x from-y)
- (and ($ on?)
- (match ($ timer)
- (0 'electron-head)
- (1 'electron-tail)
- (_ 'copper))))
+ (('wire-state grid-info from from-x from-y) (wire-state))
(('update-wire-state grid-info neighbor-grid) #f)
(('alive?) #t)
(('on?) ($ on?))
- (('describe) `(switched-emitter ,position ,($ on?)))
+ (('describe) `(switched-emitter ,position ,(wire-state)))
(('collide other offset grid-info) #f)))
(define (first-non-player-occupant grid-info x y)
diff --git a/modules/game/levels/level-4.tmx b/modules/game/levels/level-4.tmx
index 30fdd9f..c6c271d 100644
--- a/modules/game/levels/level-4.tmx
+++ b/modules/game/levels/level-4.tmx
@@ -62,7 +62,7 @@