-(define* (set-game-properties! #:key title width height bpp fps mode)
- (if title
- (set-screen-title! title))
- (if bpp
- (set-screen-bpp! bpp))
- (if (or width height)
- (begin
- (if (not width) (set! width (get-screen-width)))
- (if (not height) (set! height (get-screen-height)))
- (resize-screen width height)))
- (if fps
- (set-frames-per-second fps))
- (if mode
- (if (eq? mode '3d) (set-3d-mode) (set-2d-mode)))
- (get-game-properties))
-
-(define (get-game-properties)
- `((title . ,(get-screen-title)) (width . ,(get-screen-width)) (height . ,(get-screen-height)) (bpp . ,(get-screen-bpp)) (fps . ,pfps) (mode . ,pmode)))
-
-
-;;; Main Loop
-
-(define loop-flag #f)
-(define game-code #f)
-
-(define-macro (game . code)
- `(let ((game-function ,(if (null? code)
- `(lambda () #f)
- `(lambda () ,@code))))
- (set-game-code game-function)
- (cond ((not (game-running?))
- (game-loop)))))
-
-(define (init-gacela)
- (call-with-new-thread (lambda () (game))))
-
-(define (quit-gacela)
- (set! loop-flag #f))
-
-(define (game-loop)
-; (refresh-active-mobs)
- (set! loop-flag #t)
- (init-video 640 480 32)
- (while loop-flag
- (init-frame-time)
-; (check-connections)
- (process-events)
- (cond ((not (quit?))
- (clear-screen)
- (to-origin)
-; (refresh-active-mobs)
- (if (procedure? game-code)
- (catch #t
- (lambda () (game-code))
- (lambda (key . args) #f)))
-; (run-mobs)
- (flip-screen)
- (delay-frame))))
- (quit-video))
-
-(define (game-running?)
- loop-flag)
-
-(define (set-game-code game-function)
- (set! game-code game-function))