From: Matthias Braun Date: Mon, 20 Dec 2004 21:35:37 +0000 (+0000) Subject: create lisp code on the fly (still no enemies showing up in editor, no idea why.... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=7bbb0ef907ebec48718560425a0147b31307f7fd;p=supertux.git 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 SVN-Revision: 2263 --- diff --git a/src/badguy/jumpy.cpp b/src/badguy/jumpy.cpp index 4d32164ac..4059219a3 100644 --- a/src/badguy/jumpy.cpp +++ b/src/badguy/jumpy.cpp @@ -3,6 +3,8 @@ #include "jumpy.h" static const float JUMPSPEED=600; +static const float JUMPY_MID_TOLERANCE=8; +static const float JUMPY_LOW_TOLERANCE=2; Jumpy::Jumpy(const lisp::Lisp& reader) { @@ -56,7 +58,13 @@ Jumpy::active_action(float elapsed_time) dir = Sector::current()->player->get_pos().x > get_pos().x ? RIGHT : LEFT; //FIXME: add middle and up here - sprite->set_action(dir == LEFT ? "left-down" : "right-down"); + + if ( get_pos().y >= (start_position.y - JUMPY_MID_TOLERANCE) ) + sprite->set_action(dir == LEFT ? "left-middle" : "right-middle"); + else if ( get_pos().y >= (start_position.y - JUMPY_LOW_TOLERANCE) ) + sprite->set_action(dir == LEFT ? "left-down" : "right-down"); + else + sprite->set_action(dir == LEFT ? "left-up" : "right-up"); } IMPLEMENT_FACTORY(Jumpy, "jumpy") diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index fc1eb2676..1f1692def 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -861,7 +861,7 @@ void LevelEditor::change(int x, int y, int newtile, int layer) 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++; diff --git a/src/object_factory.cpp b/src/object_factory.cpp index 9ce2686a6..bd93f21da 100644 --- a/src/object_factory.cpp +++ b/src/object_factory.cpp @@ -21,6 +21,8 @@ #include #include +#include "lisp/lisp.h" +#include "lisp/parser.h" #include "object_factory.h" Factories* object_factories = 0; @@ -37,3 +39,14 @@ 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; + std::auto_ptr lisp (parser.parse(lisptext)); + return create_object(name, *lisp); +} diff --git a/src/object_factory.h b/src/object_factory.h index 7cb3f8f02..7e578356f 100644 --- a/src/object_factory.h +++ b/src/object_factory.h @@ -35,12 +35,6 @@ public: * 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 Factories;