From 475d22be2375535402165d3373fae03a028886f2 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Thu, 19 Jan 2017 20:19:29 +0100 Subject: [PATCH] Quit game support --- .../02-event-driven-programming.scm | 22 +++++++++++ examples/02-event-driven-programming/x.bmp | Bin 0 -> 921656 bytes gacela/event.scm | 37 ++++++++++++++++++ gacela/game.scm | 3 +- 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 examples/02-event-driven-programming/02-event-driven-programming.scm create mode 100755 examples/02-event-driven-programming/x.bmp create mode 100644 gacela/event.scm diff --git a/examples/02-event-driven-programming/02-event-driven-programming.scm b/examples/02-event-driven-programming/02-event-driven-programming.scm new file mode 100644 index 0000000..903a6a5 --- /dev/null +++ b/examples/02-event-driven-programming/02-event-driven-programming.scm @@ -0,0 +1,22 @@ +#!/usr/bin/env guile +!# + +;;; Gacela, a GNU Guile extension for fast games development +;;; Copyright (C) 2017 by Javier Sancho Fernandez +;;; +;;; This program is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + +(use-modules (gacela)) + +(run-scene (import-bitmap "x.bmp")) diff --git a/examples/02-event-driven-programming/x.bmp b/examples/02-event-driven-programming/x.bmp new file mode 100755 index 0000000000000000000000000000000000000000..9633a7e1357a05c8d2136315d8e96743db951644 GIT binary patch literal 921656 zcmeI*&&~A4mLFivYz@ zscyb(vdCt4KMl+sl1&z?o~k;BfBOCOzyA0C{4f9cn}2@(NB-}>=l}lCzkl=1|NXab zzWKLr{@Xt{fAjD8{=fdGZ~p$jzc=K6{+|y40t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0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t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N e0t5&UAV7cs0RjXF5FkK+009C7K2zYEZ~i}d(*CIc literal 0 HcmV?d00001 diff --git a/gacela/event.scm b/gacela/event.scm new file mode 100644 index 0000000..9efd8e1 --- /dev/null +++ b/gacela/event.scm @@ -0,0 +1,37 @@ +;;; Gacela, a GNU Guile extension for fast games development +;;; Copyright (C) 2017 by Javier Sancho Fernandez +;;; +;;; This program is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + + +(define-module (gacela event) + #:use-module ((sdl2 events) #:prefix sdl2:) + #:export (process-events + quit?)) + + +(define *current-events* '()) + +(define (poll-events) + (let ((event (sdl2:poll-event))) + (cond (event + (cons event (poll-events))) + (else + '())))) + +(define (process-events) + (set! *current-events* (poll-events))) + +(define (quit?) + (not (null? (filter (lambda (e) (sdl2:quit-event? e)) *current-events*)))) diff --git a/gacela/game.scm b/gacela/game.scm index dad0412..dd7886c 100644 --- a/gacela/game.scm +++ b/gacela/game.scm @@ -17,6 +17,7 @@ (define-module (gacela game) #:use-module (gacela math) + #:use-module (gacela event) #:use-module ((sdl2) #:prefix sdl2:) #:use-module ((sdl2 render) #:prefix sdl2:) #:use-module ((sdl2 surface) #:prefix sdl2:) @@ -72,7 +73,7 @@ unused accumulator time." (cond ((>= ticks max-ticks-per-frame) lag) ((>= lag tick-interval) - ;(process-events) + (process-events) ;(agenda-tick!) (iter (- lag tick-interval) (1+ ticks))) (else -- 2.39.5