5 static const float JUMPSPEED=600;
6 static const float JUMPY_MID_TOLERANCE=8;
7 static const float JUMPY_LOW_TOLERANCE=2;
9 Jumpy::Jumpy(const lisp::Lisp& reader)
11 reader.get("x", start_position.x);
12 reader.get("y", start_position.y);
13 bbox.set_size(31.8, 31.8);
14 sprite = sprite_manager->create("jumpy");
18 Jumpy::write(lisp::Writer& writer)
20 writer.start_list("jumpy");
22 writer.write_float("x", start_position.x);
23 writer.write_float("y", start_position.y);
25 writer.end_list("jumpy");
29 Jumpy::collision_solid(GameObject& , const CollisionHit& chit)
35 Jumpy::collision_badguy(BadGuy& , const CollisionHit& chit)
41 Jumpy::hit(const CollisionHit& chit)
44 if(chit.normal.y < -.5) {
45 physic.set_velocity_y(JUMPSPEED);
46 } else if(chit.normal.y < .5) { // bumped on roof
47 physic.set_velocity_y(0);
54 Jumpy::active_action(float elapsed_time)
56 BadGuy::active_action(elapsed_time);
58 dir = Sector::current()->player->get_pos().x > get_pos().x
60 //FIXME: add middle and up here
62 if ( get_pos().y >= (start_position.y - JUMPY_MID_TOLERANCE) )
63 sprite->set_action(dir == LEFT ? "left-middle" : "right-middle");
64 else if ( get_pos().y >= (start_position.y - JUMPY_LOW_TOLERANCE) )
65 sprite->set_action(dir == LEFT ? "left-down" : "right-down");
67 sprite->set_action(dir == LEFT ? "left-up" : "right-up");
70 IMPLEMENT_FACTORY(Jumpy, "jumpy")