- // if we're big, we shrink
- if(mystate == STATE_BIG) {
- mystate = STATE_INVINCIBLE;
- invincible_timer.start(INVINCIBLE_TIME);
-
- float old_x_offset = sprite->get_current_hitbox_x_offset();
- float old_y_offset = sprite->get_current_hitbox_y_offset();
- activate();
-
- // shrink bounding box and adjust sprite position to where the stump once was
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
- Vector pos = get_pos();
- pos.x += sprite->get_current_hitbox_x_offset() - old_x_offset;
- pos.y += sprite->get_current_hitbox_y_offset() - old_y_offset;
- set_pos(pos);
-
- sound_manager->play("sounds/mr_tree.ogg", get_pos());
- player.bounce(*this);
-
- Vector leaf1_pos = Vector(pos.x - POISONIVY_WIDTH - 1, pos.y - POISONIVY_Y_OFFSET);
- Rect leaf1_bbox = Rect(leaf1_pos.x, leaf1_pos.y, leaf1_pos.x + POISONIVY_WIDTH, leaf1_pos.y + POISONIVY_HEIGHT);
- if (Sector::current()->is_free_space(leaf1_bbox)) {
- PoisonIvy* leaf1 = new PoisonIvy(leaf1_bbox.p1.x, leaf1_bbox.p1.y, LEFT);
- Sector::current()->add_object(leaf1);
- }
- Vector leaf2_pos = Vector(pos.x + sprite->get_current_hitbox_width() + 1, pos.y - POISONIVY_Y_OFFSET);
- Rect leaf2_bbox = Rect(leaf2_pos.x, leaf2_pos.y, leaf2_pos.x + POISONIVY_WIDTH, leaf2_pos.y + POISONIVY_HEIGHT);
- if (Sector::current()->is_free_space(leaf2_bbox)) {
- PoisonIvy* leaf2 = new PoisonIvy(leaf2_bbox.p1.x, leaf2_bbox.p1.y, RIGHT);
- Sector::current()->add_object(leaf2);
- }
-
- 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.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));