From: jsancho Date: Sun, 12 Dec 2010 09:18:14 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=6b6a4339ce465b8fed0fd017c981d0b5953a5175;p=gacela.git --- diff --git a/Makefile b/Makefile index d73950b..23c1979 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ INC = -I/usr/include/FTGL -I/usr/include/freetype2 LIBS = -lSDL -lSDL_image -lSDL_mixer -lSDL_gfx -lGL -lGLU -lftgl OBJ = gacela.o gacela_misc.o gacela_SDL.o gacela_GL.o gacela_FTGL.o \ - gacela_draw.o gacela_ttf.o gacela_events.o gacela_mobs.o \ + gacela_draw.o gacela_ttf.o gacela_events.o gacela_mobs.o gacela_boxes.o \ gacela_widgets.o gacela_sound.o GCL_OBJ = $(OBJ:%.o=\"%.o\") diff --git a/gacela.lisp b/gacela.lisp index 299ab90..cc875b4 100644 --- a/gacela.lisp +++ b/gacela.lisp @@ -285,7 +285,9 @@ (do () ((quit?)) (glClear (+ GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT)) (to-origin) + (refresh-visible-boxes) (when (functionp game-code) (funcall game-code)) + (render-boxes) (SDL_GL_SwapBuffers) (delay-frame) (init-frame-time) @@ -304,7 +306,8 @@ (free-all-resources) (quit-audio) (quit-video-mode) - (quit-all-mobs) +; (quit-all-mobs) + (quit-all-boxes) ; (clear-events) ; (quit-events) (quit-sdl)) diff --git a/gacela_boxes.lisp b/gacela_boxes.lisp new file mode 100755 index 0000000..61ab0a4 --- /dev/null +++ b/gacela_boxes.lisp @@ -0,0 +1,67 @@ +;;; Gacela, a GNU Common Lisp extension for fast games development +;;; Copyright (C) 2009 by Javier Sancho Fernandez +;;; +;;; This program is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + + +(eval-when (compile load eval) + (when (not (find-package 'gacela)) (make-package 'gacela :nicknames '(gg) :use '(lisp))) + (in-package 'gacela :nicknames '(gg) :use '(lisp))) + + +;;; Boxes Factory + +(let (visible-boxes boxes-to-add boxes-to-quit) + (defun add-box (box) + (push box boxes-to-add)) + + (defun quit-box (box) + (push box boxes-to-quit)) + + (defun quit-all-boxes () + (setq visible-boxes nil boxes-to-add nil boxes-to-quit nil)) + + (defun refresh-visible-boxes () + (cond (boxes-to-add + (setq visible-boxes (union visible-boxes boxes-to-add)) + (setq boxes-to-add nil))) + (cond (boxes-to-quit + (setq visible-boxes (reverse (set-difference visible-boxes boxes-to-quit))) + (setq boxes-to-quit nil)))) + + (defun render-boxes () + (labels ((render (l) + (cond (l (funcall (render-fun-name (car l))) + (render (cdr l)))))) + (render visible-boxes)))) + + +(defun render-fun-name (name) + (intern (concatenate 'string "RENDER-BOX-" (string name)) 'gacela)) + +(defun get-props-fun-name (name) + (intern (concatenate 'string "GET-PROPERTIES-BOX-" (string name)) 'gacela)) + +(defmacro make-box (name properties &rest code) + `(progn + (let ,(union '((rx 0) (ry 0) (rz 0)) properties) + (defun ,(render-fun-name name) () ,@code) + (defun ,(get-props-fun-name name) () (list :rx rx :ry ry :rz rz))) + (add-box ',name))) + + +;;; Translations and rotations + +(defun rotate-box (&rest rot) + ) \ No newline at end of file