Hi Janiho

This should help get you get going ...

The function big-bang takes minimally:
*  an initial "state of the world",
* a function that  that takes the current world state and evolves it with
every tick of a notional clock, and
* a function that takes the state of the world and draws it.

In this case there's no dependence on the existing state, so the function
random-state ignores what is passed in, but it has the necessary form to
work with big-bang.

Exercise: add a counter to the world state that increments with every tick,
and show this as a number in the top-left corner of the animated image.

Dan


#lang racket

(require 2htdp/universe)
(require 2htdp/image)

(struct world (foreground background))

(define (random-color)
  (make-color (random 255) (random 255) (random 255)))

(define (random-state current)
  (world (random-color) (random-color)))

(define (SUPER state)
  (overlay (text "SUPER" 105 (world-foreground state))
           (circle 200 "solid" (world-background state))))

(big-bang (random-state null)
          (on-tick random-state 0.3) ; change the image every 0.3 seconds
          (to-draw SUPER))

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to