#:use-module (ice-9 optargs)
#:export (load-texture
load-font
+ *title*
+ *width-screen*
+ *height-screen*
+ *bpp-screen*
+ *frames-per-second*
+ *mode*
set-game-properties!
get-game-properties
init-gacela
;;; Game Properties
-(define title "Gacela")
-(define width-screen 640)
-(define height-screen 480)
-(define bpp-screen 32)
-(define frames-per-second 20)
-(define mode '2d)
+(define *title* "Gacela")
+(define *width-screen* 640)
+(define *height-screen* 480)
+(define *bpp-screen* 32)
+(define *frames-per-second* 20)
+(define *mode* '2d)
(define* (set-game-properties! #:key title width height bpp fps mode)
(if title
(if (not height) (set! height (get-screen-height)))
(resize-screen width height)))
(if fps
- (set-frames-per-second 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)))
+ `((title . ,(get-screen-title)) (width . ,(get-screen-width)) (height . ,(get-screen-height)) (bpp . ,(get-screen-bpp)) (fps . ,(get-frames-per-second)) (mode . ,(if (3d-mode?) '3d '2d))))
;;; Main Loop
(define (game-loop)
; (refresh-active-mobs)
(set! loop-flag #t)
- (init-video 640 480 32)
+ (init-video *width-screen* *height-screen* *bpp-screen* #:title *title* #:mode *mode* #:fps *frames-per-second*)
(while loop-flag
(init-frame-time)
; (check-connections)
(process-events)
- (cond ((not (quit?))
+ (cond ((quit-signal?)
+ (quit-gacela))
+ (else
(clear-screen)
(to-origin)
; (refresh-active-mobs)
set-2d-mode
set-3d-mode
3d-mode?
- set-frames-per-second
+ get-frames-per-second
+ set-frames-per-second!
init-frame-time
get-frame-time
delay-frame
(define screen #f)
(define flags 0)
-(define* (init-video width height bpp #:key (mode '2d) (title ""))
+(define* (init-video width height bpp #:key (mode '2d) (title "") (fps 20))
(cond ((not screen)
(SDL_Init SDL_INIT_VIDEO)
(let ((info (SDL_GetVideoInfo)))
(if (= (assoc-ref info 'blit_hw) 0) 0 SDL_HWACCEL)))
(set! screen (SDL_SetVideoMode width height bpp flags))
(set-screen-title! title)
+ (set-frames-per-second! fps)
(init-gl)
(if (eq? mode '3d) (set-3d-mode) (set-2d-mode))))))
(surface-w screen))
(define (get-screen-bpp)
- (surface-format-BytesPerPixel screen))
+ (* (surface-format-BytesPerPixel screen) 8))
(define (set-screen-bpp! bpp)
(cond (screen
;;; Frames per second
(define time 0)
+(define frames-per-second 20)
(define time-per-frame 50) ;in ms
-(define (set-frames-per-second fps)
+(define (get-frames-per-second)
+ frames-per-second)
+
+(define (set-frames-per-second! fps)
+ (set! frames-per-second fps)
(set! time-per-frame (/ 1000.0 fps)))
(define (init-frame-time)