(define-module (gacela gacela)
#:use-module (gacela events)
#:use-module (gacela video)
- #:use-module ((gacela video) #:renamer (symbol-prefix-proc 'video:))
#:use-module (gacela audio)
#:use-module (ice-9 optargs)
#:export (*title*
define-mob
lambda-mob
define-checking-mobs)
- #:re-export (translate
- get-frame-time
+ #:re-export (get-frame-time
3d-mode?))
(to-origin)
(refresh-active-mobs)
(run-mobs)
- (draw-bricks)
+ (run-extensions)
(flip-screen)
(delay-frame))))
(quit-video))
loop-flag)
+;;; Extensions to main loop
+
+(define extensions '())
+
+(define (add-extension! proc pri)
+ "Add an extension with a priority to the main loop"
+ (set! extensions
+ (sort (assoc-set! extensions proc pri)
+ (lambda (a b)
+ (< (cdr a) (cdr b))))))
+
+(define (remove-extension! proc)
+ "Remove an extension from the main loop"
+ (set! extensions
+ (assoc-remove! extensions proc)))
+
+(define (run-extensions)
+ (for-each (lambda (x) ((car x))) extensions))
+
+
;;; Game Properties
(define *title* "Gacela")
,@body))
-;;; Bricks Factory
-
-(define active-bricks '())
-
-(define* (draw-bricks #:optional (bricks active-bricks))
- (cond ((not (null? bricks))
- ((car bricks))
- (draw-bricks (cdr bricks)))))
-
-(define-macro (show-brick brick-name)
- `(set! active-bricks (cons (lambda () (,brick-name)) active-bricks)))
-
-(define-macro (simple-brick brick-code)
- (let ((name (gensym)))
- `(begin
- (define (,name)
- ,brick-code)
- (show-brick ,name)
- ,name)))
-
-
-;;; Primitive bricks
-
-(define-macro (draw-square . args)
- `(simple-brick (apply video:draw-square ',args)))
-
-(re-export video:draw-square)
-
-
(module-map (lambda (sym var)
(if (not (eq? sym '%module-public-interface))
(module-export! (current-module) (list sym))))