[Super-tux-commit] supertux/src leveleditor.cpp,1.175,1.176 object_factory.cpp,1.1,1.2 object_factor
Brought to you by:
wkendrick
From: Matze B. <mat...@us...> - 2004-12-20 21:36:06
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31819/src Modified Files: leveleditor.cpp object_factory.cpp object_factory.h Log Message: create lisp code on the fly (still no enemies showing up in editor, no idea why...) also incorporated another patch from Ondra which brings back the jumpy animations Index: object_factory.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/object_factory.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- object_factory.h 20 Dec 2004 21:24:25 -0000 1.1 +++ object_factory.h 20 Dec 2004 21:35:36 -0000 1.2 @@ -35,12 +35,6 @@ * Remember to delete the objects later */ virtual GameObject* create_object(const lisp::Lisp& reader) = 0; - - // hack for now will be removed later - virtual GameObject* create_object(const Vector& ) - { - return 0; - } }; typedef std::map<std::string, Factory*> Factories; Index: object_factory.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/object_factory.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- object_factory.cpp 20 Dec 2004 21:24:25 -0000 1.1 +++ object_factory.cpp 20 Dec 2004 21:35:36 -0000 1.2 @@ -21,6 +21,8 @@ #include <sstream> #include <stdexcept> +#include "lisp/lisp.h" +#include "lisp/parser.h" #include "object_factory.h" Factories* object_factories = 0; @@ -37,3 +39,14 @@ return i->second->create_object(reader); } +GameObject* create_object(const std::string& name, const Vector& pos) +{ + std::stringstream lisptext; + lisptext << "(" << name + << " (x " << pos.x << ")" + << " (y " << pos.y << "))"; + + lisp::Parser parser; + std::auto_ptr<lisp::Lisp> lisp (parser.parse(lisptext)); + return create_object(name, *lisp); +} Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.175 retrieving revision 1.176 diff -u -d -r1.175 -r1.176 --- leveleditor.cpp 20 Dec 2004 21:24:22 -0000 1.175 +++ leveleditor.cpp 20 Dec 2004 21:35:36 -0000 1.176 @@ -861,7 +861,7 @@ for(Factories::iterator i = object_factories->begin(); i != object_factories->end(); ++i) { if(id == newtile - gameobjs_first_id) { - object = i->second->create_object(Vector(x, y)); + object = create_object(i->first, Vector(x, y)); break; } id++; |