X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fgacela.scm;h=248f1835ffbbf14201cc579cc958c95db6000e14;hb=4487eb2a881092ebebd5496e6425fa8f07546c0f;hp=38b57f01988a5eaa4642132db74711ca3b80a65c;hpb=927bc117a8d08f73cfce9087e04ad6b169280edb;p=gacela.git diff --git a/src/gacela.scm b/src/gacela.scm index 38b57f0..248f183 100644 --- a/src/gacela.scm +++ b/src/gacela.scm @@ -106,13 +106,13 @@ (glEnable GL_LIGHTING)) (define (resize-screen-GL width height) - (glViewPort 0 0 width height) + (glViewport 0 0 width height) (glMatrixMode GL_PROJECTION) (glLoadIdentity) (cond ((3d-mode?) (let ((ratio (if (= height 0) width (/ width height)))) (gluPerspective 45 ratio 0.1 100))) ;0.1 - (else (let* ((w (/ width 2)) (-w (neg w)) (h (/ height 2)) (-h (neg h))) - (glOrtho -w w -h h 0 1)))) + (else (let* ((w (/ width 2)) (h (/ height 2))) + (glOrtho (- w) w (- h) h 0 1)))) (glMatrixMode GL_MODELVIEW) (glLoadIdentity) #t) @@ -208,7 +208,9 @@ (define-macro (run-game . code) - `(let ((game-function (lambda () ,@code))) + `(let ((game-function ,(if (null? code) + `(lambda () #f) + `(lambda () ,@code)))) (init-video-mode) (set-game-code game-function) (cond ((not (game-running?)) @@ -218,21 +220,23 @@ (define game-running? #f) (define set-game-code #f) -(let ((running #f) (game-code #f)) +(let ((running #f) (game-code #f) (mobs '())) (set! game-loop (lambda () + (set! mobs (get-active-mobs)) (set! running #t) + (quit? #f) (do () ((quit?)) (init-frame-time) - (check-connections) - (eval-from-clients) +; (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) + (cond ((mobs-changed?) (set! mobs (get-active-mobs)))) + (if (procedure? game-code) (game-code)) + (process-mobs mobs) (SDL_GL_SwapBuffers) (delay-frame)))) (set! running #f))) @@ -246,11 +250,10 @@ (set! game-code game-function)))) (define (quit-game) -; (free-all-resources) (quit-audio) (quit-video-mode) ; (quit-all-mobs) ; (kill-all-objects) -; (clear-events) -; (quit-events) +; (clear-events) + (quit-events) (quit-sdl))