Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (aimant)
- (local [
- ;(define rand_color (make-color (random 256) (random 256) (random 256)))
- (define WIDTH 800)
- (define HEIGHT 800)
- (define MAGNET_RADIUS 100)
- (define BALL_PARTICLE_RADIUS 10)
- (define FOND (underlay(rectangle WIDTH HEIGHT 'solid "yellow")
- (circle MAGNET_RADIUS 'solid "red")))
- (define-struct bille(x y dx dy color)) ;particules de billes
- ;(define BILLE (circle BALL_PARTICLE_RADIUS 'solid (make-color (random 256) (random 256) (random 256))))
- (define (random-bille)
- (make-bille 0 400 (+ 5 (random 6)) (- (random 11)) (make-color (random 256) (random 256) (random 256)) ))
- ;le monde est une liste de billes
- (define INIT
- (build-list 400 (lambda (i) (random-bille))))
- (define (suivant L) ;monde -> monde
- (if (empty? L)
- L
- (local [(match-define (bille x y dx dy color) (first L))]
- (cond ((or (> x WIDTH) (> y HEIGHT))
- (cons (random-bille) (suivant (rest L))))
- ((< (+ (sqr (- x 400)) (sqr (- y 400))) 10000)
- (suivant (rest L)))
- (else (cons (make-bille (+ x dx) (+ y dy) dx (+ dy #i0.3) color) (suivant(rest L))))))))
- (define (dessiner L)
- (if (empty? L)
- FOND
- (local [(match-define (bille x y dx dy color) (first L))
- (define BILLE2 (circle BALL_PARTICLE_RADIUS 'solid color))]
- (place-image BILLE2 x y (dessiner (rest L))))))]
- (big-bang INIT
- (on-tick suivant 1/20)
- (on-draw dessiner)
- )))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement