From 0678570f5ab17948ac2c1c23821abbcbc0a8bbb6 Mon Sep 17 00:00:00 2001 From: jsancho Date: Tue, 21 Dec 2010 20:39:47 +0000 Subject: [PATCH] --- Makefile | 2 +- gacela_boxes.lisp => gacela_entities.lisp | 35 +++++++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) rename gacela_boxes.lisp => gacela_entities.lisp (74%) diff --git a/Makefile b/Makefile index 23c1979..ec24457 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_boxes.o \ + gacela_draw.o gacela_ttf.o gacela_events.o gacela_mobs.o gacela_entities.o \ gacela_widgets.o gacela_sound.o GCL_OBJ = $(OBJ:%.o=\"%.o\") diff --git a/gacela_boxes.lisp b/gacela_entities.lisp similarity index 74% rename from gacela_boxes.lisp rename to gacela_entities.lisp index 61ab0a4..c4ac79b 100755 --- a/gacela_boxes.lisp +++ b/gacela_entities.lisp @@ -20,6 +20,35 @@ (in-package 'gacela :nicknames '(gg) :use '(lisp))) +;;; Behaviours of entities + +(defmacro make-behaviour (name properties &rest code) + `(defun ,name (entity) + (let ,(mapcar #'property-definition properties) + ,@code + ,(cons 'progn (mapcar #'property-save properties)) + entity))) + +(defun property-name (property) + (intern (string property) 'keyword)) + +(defun property-definition (property) + (let* ((name (cond ((listp property) (car property)) + (t property))) + (pname (property-name name)) + (value (cond ((listp property) (cadr property))))) + `(,name (getf entity ,pname ,value)))) + +(defun property-save (property) + (let* ((name (cond ((listp property) (car property)) + (t property))) + (pname (property-name name))) + `(setf (getf entity ,pname) ,name))) + + + +;;; Constructor + ;;; Boxes Factory (let (visible-boxes boxes-to-add boxes-to-quit) @@ -59,9 +88,3 @@ (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 -- 2.39.5