From fd6032e61930e10fc10b41e43acf98674998288a Mon Sep 17 00:00:00 2001 From: jsancho Date: Fri, 9 Dec 2011 19:24:03 +0000 Subject: [PATCH] Gacela as Guile modules. --- src/audio.scm | 5 +++-- src/{gacela_events.scm => events.scm} | 9 +++++++++ src/gacela.scm | 12 ++++++++++++ src/gacela_loader.scm | 25 ------------------------- src/video.scm | 7 ++++--- 5 files changed, 28 insertions(+), 30 deletions(-) rename src/{gacela_events.scm => events.scm} (96%) delete mode 100644 src/gacela_loader.scm diff --git a/src/audio.scm b/src/audio.scm index 41207f4..8b1e146 100644 --- a/src/audio.scm +++ b/src/audio.scm @@ -33,5 +33,6 @@ (set! quit-audio (lambda () - (Mix_CloseAudio) - (set! audio #f)))) + (cond (audio + (Mix_CloseAudio) + (set! audio #f)))))) diff --git a/src/gacela_events.scm b/src/events.scm similarity index 96% rename from src/gacela_events.scm rename to src/events.scm index 56099b3..d1962da 100644 --- a/src/gacela_events.scm +++ b/src/events.scm @@ -15,6 +15,15 @@ ;;; along with this program. If not, see . +(define-module (gacela events) + #:use-module (gacela sdl) + #:export (process-events + quit? + key? + key-pressed? + key-released?)) + + (define (get-event events types) (cond ((null? events) '()) (else diff --git a/src/gacela.scm b/src/gacela.scm index a45337a..52b0442 100644 --- a/src/gacela.scm +++ b/src/gacela.scm @@ -15,6 +15,14 @@ ;;; along with this program. If not, see . +(define-module (gacela gacela) + #:use-module (gacela events) + #:use-module (gacela video) + #:use-module (gacela audio) + #:use-module (ice-9 optargs) + #:export ()) + + ;;; Default values for Gacela (define *title* "Gacela") @@ -41,6 +49,10 @@ (lambda (key res) (hash-set! resources-cache key res)))) +(define-macro (use-cache-with-procedure proc-name) + `(begin + (define ,(string->symbol (string-concatenate (list (symbol->string proc-name) "-without-cache"))) ,proc-name))) + ;;; GaCeLa Functions diff --git a/src/gacela_loader.scm b/src/gacela_loader.scm deleted file mode 100644 index 23b0951..0000000 --- a/src/gacela_loader.scm +++ /dev/null @@ -1,25 +0,0 @@ -;;; Gacela, a GNU Guile extension for fast games development -;;; Copyright (C) 2009 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 . - - -(primitive-load-path "gacela.scm") -(primitive-load-path "gacela_events.scm") -(primitive-load-path "gacela_draw.scm") -(primitive-load-path "gacela_ttf.scm") -(primitive-load-path "gacela_mobs.scm") -(primitive-load-path "gacela_misc.scm") -(primitive-load-path "gacela_server.scm") -(primitive-load-path "gacela_widgets.scm") diff --git a/src/video.scm b/src/video.scm index 92d1ca8..fbd98b7 100644 --- a/src/video.scm +++ b/src/video.scm @@ -98,9 +98,10 @@ (set! quit-video (lambda () - (SDL_FreeSurface screen) - (set! screen #f) - (SDL_Quit)))) + (cond (screen + (SDL_FreeSurface screen) + (set! screen #f) + (SDL_Quit)))))) (define (clear-screen) (glClear (+ GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT))) -- 2.39.5