Exemplo n.º 1
0
void positional_source::update(unsigned int time, const display &disp)
{
	if (time - last_played_ < unsigned(min_delay_) || sound::is_sound_playing(id_))
		return;

	int i = rand() % 100 + 1;

	if(i <= chance_) {
		last_played_ = time;

		// If no locations have been specified, treat the source as if
		// it was present everywhere on the map
		if(locations_.empty()) {
			sound::play_sound_positioned(files_, id_, loops_, 0);	// max volume
			return;
		}

		int distance_volume = DISTANCE_SILENT;
		for(std::vector<map_location>::iterator i = locations_.begin(); i != locations_.end(); ++i) {
			int v = calculate_volume(*i, disp);
			if(v < distance_volume) {
				distance_volume = v;
			}
		}

		if(distance_volume >= DISTANCE_SILENT)
			return;

		sound::play_sound_positioned(files_, id_, loops_, distance_volume);
	}
}
Exemplo n.º 2
0
int main() {
  int t;
  scanf("%d", &t);
  while(t--) {
    double AB, AC, AD, BC, BD, CD;
    scanf("%lf %lf %lf %lf %lf %lf", &AB, &AC, &AD, &BC, &BD, &CD);
    printf("%.4lf\n", calculate_volume(AB, BC, AC, CD, AD, BD));
  }
  return 0;
}
Exemplo n.º 3
0
void positional_source::update_positions(unsigned int time, const display &disp)
{
	int distance_volume = DISTANCE_SILENT;
	for(std::vector<map_location>::iterator i = locations_.begin(); i != locations_.end(); ++i) {
		if(disp.shrouded(*i) || (check_fogged_ && disp.fogged(*i)))
			continue;

		int v = calculate_volume(*i, disp);
		if(v < distance_volume) {
			distance_volume = v;
		}
	}

	if(sound::is_sound_playing(id_)) {
		sound::reposition_sound(id_, distance_volume);
	} else {
		update(time, disp);
	}
}
Exemplo n.º 4
0
void positional_source::update_positions(unsigned int time, const display &disp)
{
	if(is_global()) {
		return;
	}

	int distance_volume = DISTANCE_SILENT;
	for(std::vector<map_location>::iterator i = locations_.begin(); i != locations_.end(); ++i) {
		int v = calculate_volume(*i, disp);
		if(v < distance_volume) {
			distance_volume = v;
		}
	}

	if(sound::is_sound_playing(id_)) {
		sound::reposition_sound(id_, distance_volume);
	} else {
		update(time, disp);
	}
}
unsigned int calculate_ribbon_length(const Present& present) {
    unsigned int length_of_two_shortest_sides = calculate_length_of_two_shortest_sides(present);
    unsigned int volume = calculate_volume(present);

    return 2*length_of_two_shortest_sides + volume;
}