added jam build system, please try it out - the advantage would be that it already...
[supertux.git] / src / badguy / jumpy.cpp
1 #include <config.h>
2
3 #include "jumpy.h"
4
5 static const float JUMPSPEED=600;
6
7 Jumpy::Jumpy(LispReader& reader)
8 {
9   reader.read_float("x", start_position.x);
10   reader.read_float("y", start_position.y);
11   bbox.set_size(32, 32);
12   sprite = sprite_manager->create("jumpy");
13 }
14
15 void
16 Jumpy::write(LispWriter& writer)
17 {
18   writer.start_list("jumpy");
19
20   writer.write_float("x", get_pos().x);
21   writer.write_float("y", get_pos().y);
22
23   writer.end_list("jumpy");
24 }
25
26 HitResponse
27 Jumpy::collision_solid(GameObject& , const CollisionHit& hit)
28 {
29   // hit floor?
30   if(hit.normal.y < -.5) {
31     physic.set_velocity_y(JUMPSPEED);
32   } else if(hit.normal.y < .5) { // bumped on roof
33     physic.set_velocity_y(0);
34   }
35
36   return CONTINUE;
37 }
38