Add particle effects for pickups, e-switches, and warps.
This commit is contained in:
parent
4d507e472f
commit
76fdb7c6f6
4 changed files with 70 additions and 19 deletions
Binary file not shown.
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
Binary file not shown.
85
game.scm
85
game.scm
|
@ -275,6 +275,67 @@
|
|||
(show-effect! (make-fade-out+in-effect 2.0 k))))
|
||||
(load-level! 0))))
|
||||
|
||||
(define (emit-pickup-particles x y)
|
||||
(run-script
|
||||
(lambda ()
|
||||
(do ((i 0 (1+ i)))
|
||||
((= i 24))
|
||||
(let ((angle (* (random) 2.0 pi))
|
||||
(r (/ tile-width 2.0)))
|
||||
(particle-pool-add! particles 140 2
|
||||
(+ (* x tile-width)
|
||||
(/ tile-width 2.0)
|
||||
(* (cos angle) r))
|
||||
(+ (* y tile-height)
|
||||
(/ tile-height 2.0)
|
||||
(* (sin angle) r))
|
||||
0.0 0.0))
|
||||
(wait 1)))))
|
||||
|
||||
(define (emit-electric-switch-particles x y)
|
||||
(run-script
|
||||
(lambda ()
|
||||
(do ((i 0 (1+ i)))
|
||||
((= i 4))
|
||||
(let ((angle (+ (* (random) pi) pi))
|
||||
(speed (+ (random) 3.0)))
|
||||
(particle-pool-add! particles 141 6
|
||||
(+ (* x tile-width)
|
||||
(/ tile-width 2.0))
|
||||
(+ (* y tile-height) 3.0)
|
||||
(* (cos angle) speed)
|
||||
(* (sin angle) speed)))
|
||||
(wait 1)))))
|
||||
|
||||
(define (emit-warp-particles x y)
|
||||
(run-script
|
||||
(lambda ()
|
||||
(do ((i 0 (1+ i)))
|
||||
((= i 4))
|
||||
(particle-pool-add! particles 142 6
|
||||
(+ (* x tile-width)
|
||||
(/ tile-width 2.0)
|
||||
(- (* (random) 6.0) 3.0))
|
||||
(+ (* y tile-height) tile-height)
|
||||
0.0
|
||||
(- (* (random) -2.0) 3.0))
|
||||
(wait 2)))))
|
||||
|
||||
(define (emit-explosion-particles x y)
|
||||
(run-script
|
||||
(lambda ()
|
||||
(do ((i 0 (1+ i)))
|
||||
((= i 16))
|
||||
(do ((j 0 (1+ j)))
|
||||
((= j 2))
|
||||
(let ((dx (- (* (random) tile-width 3.0) tile-width))
|
||||
(dy (- (* (random) tile-height 3.0) tile-height)))
|
||||
(particle-pool-add! particles 51 8
|
||||
(+ (* x tile-width) dx)
|
||||
(+ (* y tile-height) dy)
|
||||
0.0 0.0)))
|
||||
(wait 1)))))
|
||||
|
||||
;; Update loop
|
||||
(define (move-player dir)
|
||||
(define level-complete? #f)
|
||||
|
@ -301,7 +362,8 @@
|
|||
(('player-death x y)
|
||||
(play-sound-effect audio:die))
|
||||
(('pickup x y)
|
||||
(play-sound-effect audio:pickup))
|
||||
(play-sound-effect audio:pickup)
|
||||
(emit-pickup-particles x y))
|
||||
(('emit x y)
|
||||
(play-sound-effect audio:emit))
|
||||
(('emitter-on x y)
|
||||
|
@ -316,28 +378,17 @@
|
|||
((or ('floor-switch-on x y) ('floor-switch-off x y))
|
||||
(play-sound-effect audio:floor-switch))
|
||||
(('electric-switch-on x y)
|
||||
(play-sound-effect audio:electric-switch-on))
|
||||
(play-sound-effect audio:electric-switch-on)
|
||||
(emit-electric-switch-particles x y))
|
||||
(('electric-switch-off x y)
|
||||
(play-sound-effect audio:electric-switch-off))
|
||||
(('receive-electron x y)
|
||||
(play-sound-effect audio:warp 0.25))
|
||||
(play-sound-effect audio:warp 0.25)
|
||||
(emit-warp-particles x y))
|
||||
(('explosion x y)
|
||||
(play-sound-effect audio:explosion)
|
||||
(show-effect! (make-screen-shake-effect 0.2))
|
||||
(run-script
|
||||
(lambda ()
|
||||
(do ((i 0 (1+ i)))
|
||||
((= i 16))
|
||||
(do ((j 0 (1+ j)))
|
||||
((= j 2))
|
||||
(let ((angle (* (random) 2.0 pi))
|
||||
(dx (- (* (random) tile-width 3.0) tile-width))
|
||||
(dy (- (* (random) tile-height 3.0) tile-height)))
|
||||
(particle-pool-add! particles 51 8
|
||||
(+ (* x tile-width) dx)
|
||||
(+ (* y tile-height) dy)
|
||||
0.0 0.0)))
|
||||
(wait 1)))))
|
||||
(emit-explosion-particles x y))
|
||||
(_ (values)))
|
||||
(lp rest))))
|
||||
(update-objects!)
|
||||
|
|
|
@ -300,15 +300,15 @@
|
|||
($ timer t)
|
||||
(when (= t 0)
|
||||
($ on? #f)
|
||||
($ grid-info 'append-event `(electric-switch-off ,x ,y))
|
||||
(for-each (lambda (obj)
|
||||
($ grid-info 'append-event `(electic-switch-off ,x ,y))
|
||||
($ obj 'deactivate grid-info))
|
||||
(non-player-occupants grid-info target-x target-y))))
|
||||
(when (>= (electron-head-count neighbor-grid) 1)
|
||||
($ on? #t)
|
||||
($ timer 2)
|
||||
($ grid-info 'append-event `(electric-switch-on ,x ,y))
|
||||
(for-each (lambda (obj)
|
||||
($ grid-info 'append-event `(electic-switch-on ,x ,y))
|
||||
($ obj 'activate grid-info))
|
||||
(non-player-occupants grid-info target-x target-y)))))
|
||||
(('alive?) #t)
|
||||
|
|
Loading…
Add table
Reference in a new issue