From 927bc117a8d08f73cfce9087e04ad6b169280edb Mon Sep 17 00:00:00 2001 From: jsancho Date: Sun, 15 May 2011 19:52:37 +0000 Subject: [PATCH] --- src/gacela.scm | 75 +++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/src/gacela.scm b/src/gacela.scm index 7d63068..38b57f0 100644 --- a/src/gacela.scm +++ b/src/gacela.scm @@ -51,8 +51,8 @@ (init-sdl) (SDL_GL_SetAttribute SDL_GL_DOUBLEBUFFER 1) (set! flags (+ SDL_OPENGL SDL_GL_DOUBLEBUFFER SDL_HWPALETTE SDL_RESIZABLE - (if (= (getf (SDL_GetVideoInfo) :hw_available) 0) SDL_SWSURFACE SDL_HWSURFACE) - (if (= (getf (SDL_GetVideoInfo) :blit_hw) 0) 0 SDL_HWACCEL))) + (if (= (assoc-ref (SDL_GetVideoInfo) 'hw_available) 0) SDL_SWSURFACE SDL_HWSURFACE) + (if (= (assoc-ref (SDL_GetVideoInfo) 'blit_hw) 0) 0 SDL_HWACCEL))) (set! screen (SDL_SetVideoMode width height bpp flags)) (init-GL) (resize-screen-GL width height) @@ -204,46 +204,53 @@ (set! get-game-properties (lambda () - (list :title ptitle :width pwidth :height pheight :bpp pbpp :fps pfps :mode pmode))) + `((title . ,ptitle) (width . ,pwidth) (height . ,pheight) (bpp . ,pbpp) (fps . ,pfps) (mode . ,pmode))))) -(defmacro run-game (&body code) +(define-macro (run-game . code) `(let ((game-function (lambda () ,@code))) (init-video-mode) (set-game-code game-function) (cond ((not (game-running?)) (game-loop))))) -(let (running game-code) - (defun game-loop () - (setq running t) - (do () ((quit?)) - (init-frame-time) - (check-connections) - (eval-from-clients) - (process-events) - (cond ((not (quit?)) - (glClear (+ GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) - (to-origin) - (refresh-active-objects) - (when (functionp game-code) (funcall game-code)) - (render-objects) - (SDL_GL_SwapBuffers) - (delay-frame)))) - (setq running nil)) - - (defun game-running? () - running) - - (defun set-game-code (game-function) - (setq game-code game-function))) - -(defun quit-game () - (free-all-resources) - (quit-audio) - (quit-video-mode) +(define game-loop #f) +(define game-running? #f) +(define set-game-code #f) + +(let ((running #f) (game-code #f)) + (set! game-loop + (lambda () + (set! running #t) + (do () ((quit?)) + (init-frame-time) + (check-connections) + (eval-from-clients) + (process-events) + (cond ((not (quit?)) + (glClear (+ GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) + (to-origin) + (refresh-active-objects) + (if (functionp game-code) (funcall game-code)) + (render-objects) + (SDL_GL_SwapBuffers) + (delay-frame)))) + (set! running #f))) + + (set! game-running? + (lambda () + running)) + + (set! set-game-code + (lambda (game-function) + (set! game-code game-function)))) + +(define (quit-game) +; (free-all-resources) + (quit-audio) + (quit-video-mode) ; (quit-all-mobs) - (kill-all-objects) +; (kill-all-objects) ; (clear-events) ; (quit-events) - (quit-sdl)) + (quit-sdl)) -- 2.39.5