#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)
{
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")
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++;
#include <sstream>
#include <stdexcept>
+#include "lisp/lisp.h"
+#include "lisp/parser.h"
#include "object_factory.h"
Factories* object_factories = 0;
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);
+}
* 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;