5 static const float WALKSPEED = 50;
6 static const float WALKSPEED_SMALL = 30;
8 MrTree::MrTree(const lisp::Lisp& reader)
11 reader.get("x", start_position.x);
12 reader.get("y", start_position.y);
13 bbox.set_size(84.8, 95.8);
14 sprite = sprite_manager->create("mrtree");
18 MrTree::write(lisp::Writer& writer)
20 writer.start_list("mrtree");
22 writer.write_float("x", start_position.x);
23 writer.write_float("y", start_position.y);
25 writer.end_list("mrtree");
31 if(mystate == STATE_BIG) {
32 physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
33 sprite->set_action(dir == LEFT ? "left" : "right");
35 physic.set_velocity_x(dir == LEFT ? -WALKSPEED_SMALL : WALKSPEED_SMALL);
36 sprite->set_action(dir == LEFT ? "small-left" : "small-right");
41 MrTree::collision_squished(Player& player)
43 if(mystate == STATE_BIG) {
44 mystate = STATE_NORMAL;
47 SoundManager::get()->play_sound(IDToSound(SND_SQUISH), get_pos(),
51 sprite->set_action(dir == LEFT ? "squished-left" : "squished-right");
52 kill_squished(player);
59 MrTree::collision_solid(GameObject& , const CollisionHit& hit)
61 if(fabsf(hit.normal.y) > .5) {
62 physic.set_velocity_y(0);
64 dir = dir == LEFT ? RIGHT : LEFT;
72 MrTree::collision_badguy(BadGuy& , const CollisionHit& hit)
74 if(fabsf(hit.normal.x) > .8) { // left or right hit
75 dir = dir == LEFT ? RIGHT : LEFT;
82 IMPLEMENT_FACTORY(MrTree, "mrtree")