]> git.jsancho.org Git - gacela.git/commitdiff
(no commit message)
authorjsancho <devnull@localhost>
Sun, 15 May 2011 19:52:37 +0000 (19:52 +0000)
committerjsancho <devnull@localhost>
Sun, 15 May 2011 19:52:37 +0000 (19:52 +0000)
src/gacela.scm

index 7d6306825261e44044da3f4ae1071749b462af4a..38b57f01988a5eaa4642132db74711ca3b80a65c 100644 (file)
@@ -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)
 
   (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))