From: Javier Sancho Date: Mon, 27 Mar 2017 22:56:26 +0000 (+0200) Subject: Store all events when lag is produced X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;ds=inline;h=b463d97fdd8afd06f987f5f13ab73b9502e2421b;p=gacela.git Store all events when lag is produced --- diff --git a/gacela/event.scm b/gacela/event.scm index 0422397..720e4fd 100644 --- a/gacela/event.scm +++ b/gacela/event.scm @@ -18,6 +18,7 @@ (define-module (gacela event) #:use-module ((sdl2 events) #:prefix sdl2:) #:export (process-events + clear-events quit-event? key-events any-key-down? @@ -35,8 +36,11 @@ (else '())))) +(define (clear-events) + (set! *current-events* '())) + (define (process-events) - (set! *current-events* (poll-events))) + (set! *current-events* (append *current-events* (poll-events)))) (define (quit-event?) (not (null? (filter (lambda (e) (sdl2:quit-event? e)) *current-events*)))) diff --git a/gacela/game.scm b/gacela/game.scm index e8e635a..fe5f0b3 100644 --- a/gacela/game.scm +++ b/gacela/game.scm @@ -82,6 +82,7 @@ unused accumulator time." (iter (- lag tick-interval) (1+ ticks))) (else lag))) + (clear-events) (iter lag 0)) (define (alpha lag)