]> git.jsancho.org Git - gacela.git/blobdiff - gacela.lisp
(no commit message)
[gacela.git] / gacela.lisp
index 45fc02754e2df9260c1437d5f69ed1f70969fc0f..4197d22d077e2b488fc7f692d48285aced148848 100644 (file)
 (let ((audio nil))
 
   (defun init-audio ()
-    (cond ((null audio) (progn (init-sdl) (setq audio (Mix_OpenAudio 22050 2 4096))))
+    (cond ((null audio) (progn (init-sdl) (setq audio (Mix_OpenAudio 22050 MIX_DEFAULT_FORMAT 2 4096))))
          (t audio)))
 
   (defun quit-audio ()
 (defun make-resource-font (&key filename encoding)
   `(:type font :filename ,filename :enconding ,encoding))
 
+(defun make-resource-sound (&key filename)
+  `(:type sound :filename ,filename))
+
+(defun make-resource-music (&key filename)
+  `(:type music :filename ,filename))
+
 (defmacro get-rtime (key)
   `(resource-time (gethash ,key resources-table)))
 
      (init-video-mode)
      (set-game-code game-function)
      (cond ((not (game-running?))
-           (init-frame-time)
-           (process-events)
            (game-loop)))))
 
 (let (running game-code)
   (defun game-loop ()
     (setq running t)
     (do () ((quit?))
-       (glClear (+ GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT))
-       (to-origin)
-       (when (functionp game-code) (funcall game-code))
-       (SDL_GL_SwapBuffers)
-       (delay-frame)
        (init-frame-time)
        (check-connections)
        (eval-from-clients)
-       (process-events))
+       (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? ()
 
 (defun quit-game ()
   (free-all-resources)
-;  (quit-audio)
+  (quit-audio)
   (quit-video-mode)
-  (quit-all-mobs)
+;  (quit-all-mobs)
+  (kill-all-objects)
 ;  (clear-events)
 ;  (quit-events)
   (quit-sdl))