コード例 #1
0
ファイル: soundsource.cpp プロジェクト: Heark/wesnoth
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);
	}
}
コード例 #2
0
ファイル: source.c プロジェクト: natansh/spoj
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;
}
コード例 #3
0
ファイル: soundsource.cpp プロジェクト: dodikk/iWesnoth
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);
	}
}
コード例 #4
0
ファイル: soundsource.cpp プロジェクト: Heark/wesnoth
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);
	}
}
コード例 #5
0
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;
}