Commits

Christian Kellermann committed 0dcb2e3

Only redraw when done with all events.

Comments (0)

Files changed (1)

 
 
 (define *painting* #f)
+(define *dirty* #f)
 
 ; map a coordinate to a world cell
 (define (tick-cell x y)
          (if (equal? current car)
              (cons 1 0)
              (cons 0 1)))
-        (graph-generation *world*))))
+        (set! *dirty* #t))))
 
 ; Set up our game world incl. UI
 (define *gen* 0)
        e
        (('mouse 'pressed x y 1)
         (handle-buttons (which-buttons x y))
+        (set! *painting* #t)
         (tick-cell x y))
        (('mouse 'released x y 1)
         (set! *painting* #f))
        (('key 'pressed key) (handle-key key))
        (else (void))))
     events)
+   (when *dirty*
+     (graph-generation *world*)
+     (set! *dirty* #f))
    (when *running* (run))))
 
 (run-event-loop)