X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=gacela.lisp;h=4197d22d077e2b488fc7f692d48285aced148848;hb=6a3d1ffb69036e6d4f1c239fd7d52f9bfc48d50c;hp=7a054bb1d7a96235122327402244f8668bdfa284;hpb=b6c766a1beef2b891c87400f37e2e7470208424a;p=gacela.git diff --git a/gacela.lisp b/gacela.lisp index 7a054bb..4197d22 100644 --- a/gacela.lisp +++ b/gacela.lisp @@ -67,13 +67,13 @@ (setq screen nil))) (defun set-2d-mode () - (cond ((3d-mode?) + (cond ((not (3d-mode?)) (init-video-mode) (glDisable GL_DEPTH_TEST) (apply-mode-change)))) (defun set-3d-mode () - (cond ((not (3d-mode?)) + (cond ((3d-mode?) (init-video-mode) (glClearDepth 1) (glEnable GL_DEPTH_TEST) @@ -138,7 +138,7 @@ (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 () @@ -154,6 +154,12 @@ (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))) @@ -269,23 +275,24 @@ (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? () @@ -296,9 +303,10 @@ (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))