From: jsancho Date: Thu, 18 Aug 2011 17:38:25 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=91e03880066280940b29a89eae28510e124e58cb;p=gacela.git --- diff --git a/src/gacela.scm b/src/gacela.scm index dba48e6..9bea00e 100644 --- a/src/gacela.scm +++ b/src/gacela.scm @@ -251,7 +251,10 @@ (glClear (+ GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) (to-origin))) (cond ((mobs-changed?) (set! mobs (get-active-mobs)))) - (if (procedure? game-code) (game-code)) + (if (procedure? game-code) + (catch #t + (lambda () (game-code)) + (lambda (key . args) #f))) (run-mob-actions mobs) (cond ((video-mode-on?) (render-mobs mobs) diff --git a/src/gacela_mobs.scm b/src/gacela_mobs.scm index ed55a00..8c687dc 100755 --- a/src/gacela_mobs.scm +++ b/src/gacela_mobs.scm @@ -154,6 +154,38 @@ (lambda-look ,attr ,@look)))))) mob)) +(define-macro (define-mob mob-def) + (let ((name (car mob-def)) (def (cdr mob-def))) + `(define ,name + (lambda-mob ,def)))) + +(defmacro* lambda-mob (#:key (attr '()) (action #f) (look #f)) + `(let ((attr ,attr) (action ,action) (look ,look)) + (lambda (option . params) + (case option + ((get-attr) + attr) + ((set-attr) + (if (not (null? params)) (set! attr (car params)))) + ((get-action) + action) + ((set-action) + (if (not (null? params)) (set! action (car params)))) + ((get-look) + look) + ((set-look) + (if (not (null? params)) (set! look (car params)))) + ((run-mob) + (lambda (action) + (set! attr ((cdr action) attr))) + actions)) + ((render) + (for-each + (lambda (look) + ((cdr look) attr)) + looks)))))) + + (define (get-mob-attr mob var) (let ((value (assoc-ref (mob 'get-attr) var))) (if value (car value) #f))) diff --git a/src/gacela_server.scm b/src/gacela_server.scm index fbd2b2e..8c45b20 100644 --- a/src/gacela_server.scm +++ b/src/gacela_server.scm @@ -92,7 +92,5 @@ (force-output send-channel)))) -(define connect-to-server #f) - (define (connect-to-server client-socket hostname port) (connect client-socket AF_INET (car (hostent:addr-list (gethost hostname))) port))