if(root_timer.check()) {
/* TODO indicate root with an animation */
Player* player = get_nearest_player();
- Root* root = new Root(Vector(player->get_bbox().get_left(), get_bbox().get_bottom()+ROOT_TOP_OFFSET));
- Sector::current()->add_object(root);
+ if (player) {
+ Root* root = new Root(Vector(player->get_bbox().get_left(), get_bbox().get_bottom()+ROOT_TOP_OFFSET));
+ Sector::current()->add_object(root);
+ }
}
} else if (mystate == STATE_SWALLOWING) {
if (suck_lantern) {
TreeWillOWisp::TreeWillOWisp(GhostTree* tree, const Vector& pos,
float radius, float speed)
- : BadGuy(Vector(0, 0), "images/creatures/willowisp/willowisp.sprite",
+ : BadGuy(tree->get_pos() + pos, "images/creatures/willowisp/willowisp.sprite",
LAYER_OBJECTS - 20), was_sucked(false), mystate(STATE_DEFAULT), tree(tree)
{
- treepos_delta = pos;
sound_manager->preload(SOUNDFILE);
this->radius = radius;
this->angle = 0;
this->speed = speed;
- start_position = tree->get_pos() + treepos_delta;
set_colgroup_active(COLGROUP_MOVING);
}
}
angle = fmodf(angle + elapsed_time * speed, (float) (2*M_PI));
- Vector newpos(tree->get_pos() + treepos_delta + Vector(sin(angle) * radius, 0));
+ Vector newpos(start_position + Vector(sin(angle) * radius, 0));
movement = newpos - get_pos();
float sizemod = cos(angle) * 0.8f;
/* TODO: modify sprite size */