- // if we're big, we shrink
- if(mystate == STATE_BIG) {
- mystate = STATE_NORMAL;
- activate();
-
- // shrink bounding box and adjust sprite position to where the stump once was
- bbox.set_size(42, 62);
- Vector pos = get_pos();
- pos.x += 20;
- pos.y += 23;
- set_pos(pos);
-
- sound_manager->play("sounds/mr_tree.ogg", get_pos());
- player.bounce(*this);
-
- invincible_timer.start(INVINCIBLE_TIME);
-
- return true;
- }
-
- // if we're small, but still invincible, we ignore the hit
- if (!invincible_timer.check()) {
- sound_manager->play("sounds/mr_treehit.ogg", get_pos());
- player.bounce(*this);
- return true;
+ // replace with Stumpy
+ Vector stumpy_pos = get_pos();
+ stumpy_pos.x += 20;
+ stumpy_pos.y += 25;
+ Stumpy* stumpy = new Stumpy(stumpy_pos, dir);
+ remove_me();
+ Sector::current()->add_object(stumpy);
+
+ // give Feedback
+ sound_manager->play("sounds/mr_tree.ogg", get_pos());
+ Player* player = dynamic_cast<Player*>(&object);
+ if (player) player->bounce(*this);
+
+ // spawn some particles
+ // TODO: provide convenience function in MovingSprite or MovingObject?
+ for (int px = (int)stumpy->get_bbox().p1.x; px < (int)stumpy->get_bbox().p2.x; px+=10) {
+ Vector ppos = Vector(px, stumpy->get_bbox().p1.y-5);
+ float angle = systemRandom.randf(-M_PI_2, M_PI_2);
+ float velocity = systemRandom.randf(45, 90);
+ float vx = sin(angle)*velocity;
+ float vy = -cos(angle)*velocity;
+ Vector pspeed = Vector(vx, vy);
+ Vector paccel = Vector(0, 100);
+ Sector::current()->add_object(new SpriteParticle("images/objects/particles/leaf.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1));