-bool
-Sector::add_particles(const Vector& epicenter, int number, Color color, int size, float velocity, int life_time)
-{
- add_object(new Particles(epicenter, number, color, size, velocity, life_time));
- return true;
-}
-
-/* Break a brick: */
-bool
-Sector::trybreakbrick(const Vector& pos, bool small)
-{
- Tile* tile = solids->get_tile_at(pos);
- if (!tile)
- {
- char errmsg[64];
- sprintf(errmsg, "Invalid tile at %i,%i", (int)((pos.x+1)/32*32), (int)((pos.y+1)/32*32));
- throw SuperTuxException(errmsg, __FILE__, __LINE__);
- }
-
- if (tile->attributes & Tile::BRICK)
- {
- if (tile->data > 0)
- {
- /* Get a distro from it: */
- add_bouncy_distro(
- Vector(((int)(pos.x + 1) / 32) * 32, (int)(pos.y / 32) * 32));
-
- // TODO: don't handle this in a global way but per-tile...
- if (!counting_distros)
- {
- counting_distros = true;
- distro_counter = 5;
- }
- else
- {
- distro_counter--;
- }
-
- if (distro_counter <= 0)
- {
- counting_distros = false;
- solids->change_at(pos, tile->next_tile);
- }
-
- SoundManager::get()->play_sound(IDToSound(SND_DISTRO));
- player_status.score = player_status.score + SCORE_DISTRO;
- player_status.distros++;
- return true;
- }
- else if (!small)
- {
- /* Get rid of it: */
- solids->change_at(pos, tile->next_tile);
-
- /* Replace it with broken bits: */
- add_broken_brick(Vector(
- ((int)(pos.x + 1) / 32) * 32,
- (int)(pos.y / 32) * 32), tile);
-
- /* Get some score: */
- SoundManager::get()->play_sound(IDToSound(SND_BRICK));
- player_status.score = player_status.score + SCORE_BRICK;
-
- return true;
- }
- }
-
- return false;
-}
-
-/* Empty a box: */
-void
-Sector::tryemptybox(const Vector& pos, Direction col_side)
-{
- Tile* tile = solids->get_tile_at(pos);
- if (!tile)
- {
- char errmsg[64];
- sprintf(errmsg, "Invalid tile at %i,%i", (int)((pos.x+1)/32*32), (int)((pos.y+1)/32*32));
- throw SuperTuxException(errmsg, __FILE__, __LINE__);
- }
-
-
- if (!(tile->attributes & Tile::FULLBOX))
- return;
-
- // according to the collision side, set the upgrade direction
- if(col_side == LEFT)
- col_side = RIGHT;
- else
- col_side = LEFT;
-
- int posx = ((int)(pos.x+1) / 32) * 32;
- int posy = (int)(pos.y/32) * 32 - 32;
- switch(tile->data)
- {
- case 1: // Box with a distro!
- add_bouncy_distro(Vector(posx, posy));
- SoundManager::get()->play_sound(IDToSound(SND_DISTRO));
- player_status.score = player_status.score + SCORE_DISTRO;
- player_status.distros++;
- break;
-
- case 2: // Add a fire flower upgrade!
- if (player->size == SMALL) /* Tux is small, add mints! */
- add_upgrade(Vector(posx, posy), col_side, UPGRADE_GROWUP);
- else /* Tux is big, add a fireflower: */
- add_upgrade(Vector(posx, posy), col_side, UPGRADE_FIREFLOWER);
- SoundManager::get()->play_sound(IDToSound(SND_UPGRADE));
- break;
-
- case 5: // Add an ice flower upgrade!
- if (player->size == SMALL) /* Tux is small, add mints! */
- add_upgrade(Vector(posx, posy), col_side, UPGRADE_GROWUP);
- else /* Tux is big, add an iceflower: */
- add_upgrade(Vector(posx, posy), col_side, UPGRADE_ICEFLOWER);
- SoundManager::get()->play_sound(IDToSound(SND_UPGRADE));
- break;
-
- case 3: // Add a golden herring
- add_upgrade(Vector(posx, posy), col_side, UPGRADE_STAR);
- break;
-
- case 4: // Add a 1up extra
- add_upgrade(Vector(posx, posy), col_side, UPGRADE_1UP);
- break;
- default:
- break;
- }
-
- /* Empty the box: */
- solids->change_at(pos, tile->next_tile);
-}
-
-/* Try to grab a distro: */