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/>.
18 (eval-when (compile load eval)
19 (when (not (find-package 'gacela)) (make-package 'gacela :nicknames '(gg) :use '(lisp)))
20 (in-package 'gacela :nicknames '(gg) :use '(lisp)))
25 (let (visible-boxes boxes-to-add boxes-to-quit)
27 (push box boxes-to-add))
30 (push box boxes-to-quit))
32 (defun quit-all-boxes ()
33 (setq visible-boxes nil boxes-to-add nil boxes-to-quit nil))
35 (defun refresh-visible-boxes ()
37 (setq visible-boxes (union visible-boxes boxes-to-add))
38 (setq boxes-to-add nil)))
40 (setq visible-boxes (reverse (set-difference visible-boxes boxes-to-quit)))
41 (setq boxes-to-quit nil))))
43 (defun render-boxes ()
45 (cond (l (funcall (render-fun-name (car l)))
47 (render visible-boxes))))
50 (defun render-fun-name (name)
51 (intern (concatenate 'string "RENDER-BOX-" (string name)) 'gacela))
53 (defun get-props-fun-name (name)
54 (intern (concatenate 'string "GET-PROPERTIES-BOX-" (string name)) 'gacela))
56 (defmacro make-box (name properties &rest code)
58 (let ,(union '((rx 0) (ry 0) (rz 0)) properties)
59 (defun ,(render-fun-name name) () ,@code)
60 (defun ,(get-props-fun-name name) () (list :rx rx :ry ry :rz rz)))
64 ;;; Translations and rotations
66 (defun rotate-box (&rest rot)