Commits

Christian Kellermann committed 99b6011

Clear functionality added.

Comments (0)

Files changed (1)

           (vector-set! world (random (vector-length world)) '(1 . 0)))
   'ok)
 
-(define (new-world)
+(define (new-world #!optional (points 0))
   (set! *world* (make-vector (* +rows+ +cols+) '(0 . 0)))
   (clear-screen)
   (set! *gen* 0)
   (doto *world*
-         (fill-world 200)
+         (fill-world points)
          (graph-generation)
          (draw-legend *gen*))
   (draw-buttons!)
 (define (handle-key key)
   (case key
     ((#\p) (set! *running* (not *running*)))
-    ((#\n) (new-world))
+    ((#\n) (new-world 200))
+    ((#\c) (new-world))
     ((#\q) (exit 0))
     (else (void))))
 
 
 (new-button! "Play" 550 50 60 30 (lambda () (set! *running* #t)))
 (new-button! "Pause" 550 100 60 30 (lambda () (set! *running* #f)))
-(new-button! "New" 550 150 60 30 new-world)
+(new-button! "New" 550 150 60 30 (lambda () (new-world 200)))
+(new-button! "Clear" 550 200 60 30 (lambda () (new-world)))
 (new-button! "Quit" 550 250 60 30 (lambda () (exit 0)))
 
 (world-inits new-world)