X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject_factory.cpp;h=fe89724c440ec1e674ac74d5b051df611cd973bd;hb=c8eb3938f7b08c5f91f42c1f8ad91e5567817a4d;hp=9ce2686a6c32a43b9f791a3d42492e2620c4875d;hpb=e3bb6e46812f108f093e9ad0751a945c34b18cd3;p=supertux.git diff --git a/src/object_factory.cpp b/src/object_factory.cpp index 9ce2686a6..fe89724c4 100644 --- a/src/object_factory.cpp +++ b/src/object_factory.cpp @@ -1,7 +1,8 @@ // $Id$ // -// SuperTux - A Jump'n Run +// SuperTux // Copyright (C) 2004 Ricardo Cruz +// Copyright (C) 2006 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -21,14 +22,15 @@ #include #include -#include "object_factory.h" - -Factories* object_factories = 0; +#include "lisp/lisp.hpp" +#include "lisp/parser.hpp" +#include "object_factory.hpp" +#include "math/vector.hpp" GameObject* create_object(const std::string& name, const lisp::Lisp& reader) { - Factories::iterator i = object_factories->find(name); - if(i == object_factories->end()) { + Factory::Factories::iterator i = Factory::get_factories().find(name); + if(i == Factory::get_factories().end()) { std::stringstream msg; msg << "No factory for object '" << name << "' found."; throw std::runtime_error(msg.str()); @@ -37,3 +39,16 @@ GameObject* create_object(const std::string& name, const lisp::Lisp& reader) 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; + const lisp::Lisp* lisp = parser.parse(lisptext, "create_object"); + GameObject* object = create_object(name, *lisp); + + return object; +}