1 ;;; Gacela, a GNU Common Lisp extension for fast games development
2 ;;; Copyright (C) 2009 by Javier Sancho Fernandez <jsf at jsancho dot org>
4 ;;; This program is free software: you can redistribute it and/or modify
5 ;;; it under the terms of the GNU General Public License as published by
6 ;;; the Free Software Foundation, either version 3 of the License, or
7 ;;; (at your option) any later version.
9 ;;; This program is distributed in the hope that it will be useful,
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ;;; GNU General Public License for more details.
14 ;;; You should have received a copy of the GNU General Public License
15 ;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
22 (defmacro makemob (name &rest methods)
23 `(defun ,name (&rest args &aux (option (car args)))
27 (:off (mob-off ',name)))
28 (labels ((options (m &aux (option (car m)) (body (cadr m)))
30 (t (cons (list option `(apply ,body (cdr args))) (options (cddr m)))))))
34 (let (running-mobs mobs-to-add mobs-to-quit)
36 (push mob mobs-to-add))
38 (defun run-mobs (option &key args function)
39 (dolist (mob running-mobs)
40 (cond (function (funcall function)))
41 (apply (symbol-function mob) (cons option args))))
44 (push mob mobs-to-quit))
46 (defun refresh-running-mobs ()
47 (do ((mob (pop mobs-to-add) (pop mobs-to-add))) ((null mob))
48 (push mob running-mobs)
49 (funcall (symbol-function mob) :init))
50 (setq running-mobs (reverse (set-difference running-mobs mobs-to-quit)))
51 (setq mobs-to-quit nil))
53 (defun quit-all-mobs ()
54 (setq running-mobs nil mobs-to-add nil mobs-to-quit nil)))
61 (run-mobs :render :function (lambda () (glLoadIdentity))))