-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparticle-main.scm
30 lines (26 loc) · 1019 Bytes
/
particle-main.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(define (update-particle sprite-list p dt w h)
(let* ((x (particle-x p))
(y (particle-y p))
(dr (particle-dr p))
(sprite (frame/make-sprite)))
(if (or (>= x w) (<= x 0))
(vect-scale-both-into! dr dr -1 1))
(if (or (>= y h) (<= y 0))
(vect-scale-both-into! dr dr 1 -1))
(particle-integrate p dt)
(sprite-resource-set! sprite (*test-image*))
(sprite-x-set! sprite (particle-x p))
(sprite-y-set! sprite (particle-y p))
(frame/spritelist-append sprite-list sprite)))
(define (update-view-old dt)
(call-with-resources
(lambda ()
(let ((w (- 640 (image-width (*test-image*))))
(h (- 480 (image-height (*test-image*)))))
(let loop ((ps *ps*)
(sprite-list #f))
(if (null? ps)
(if sprite-list (spritelist-enqueue-for-screen! sprite-list))
(loop (cdr ps)
(update-particle sprite-list
(car ps) dt w h))))))))