当前位置: 首页>>代码示例>>C++>>正文


C++ Query::begin方法代码示例

本文整理汇总了C++中Query::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Query::begin方法的具体用法?C++ Query::begin怎么用?C++ Query::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Query的用法示例。


在下文中一共展示了Query::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: calculate_fire_weapon

void TeronBuilder::calculate_fire_weapon()
{
	STACKTRACE;
	if ( fire_weapon && !fire_special && (thrust || turn_left || turn_right) ) {
		if ( weapon_recharge > 0 )
			return;

		if ( thrust ) {
			if ( select_all ) {
				select_all = false;
				current_drone = NULL;
				message.out( "All drones deselected" );
			} else {
				select_all = true;
				message.out( "All drones selected" );
			}

		}
		else if ( turn_right ) {
			select_all = false;
			TeronDrone* first_drone = NULL;
			TeronDrone* next_drone = NULL;
			Query q;
			for( q.begin( this, bit(LAYER_SHIPS), selectRange ); q.currento; q.next() ) {
				if ( !next_drone && sameShip( q.currento ) && q.currento->get_sprite() == data->TERON_DRONE_SPRITE ) {
					next_drone = (TeronDrone*)q.currento;
					if ( !first_drone ) first_drone = (TeronDrone*)q.currento;
				}
				if ( q.currento == current_drone ) {
					next_drone = NULL;
				}
			}
			q.end();
			if ( next_drone ) current_drone = next_drone;
			else current_drone = first_drone;
			message.out( "Next drone selected" );
		}
		else if ( turn_left ) {
			select_all = false;
			TeronDrone* prev_drone = NULL;
			Query q;
			for( q.begin( this, bit(LAYER_SHIPS), selectRange ); q.currento; q.next() ) {
				if ( q.currento == current_drone ) {
					if ( prev_drone ) break;
				}
				if ( sameShip( q.currento ) && q.currento->get_sprite() == data->TERON_DRONE_SPRITE ) {
					prev_drone = (TeronDrone*)q.currento;
				}
			}
			q.end();
			current_drone = prev_drone;
			message.out( "Prev drone selected" );
		}
		weapon_recharge += weapon_rate;

		play_sound2(data->sampleWeapon[weapon_sample]);
	}
}
开发者ID:Yurand,项目名称:tw-light,代码行数:58,代码来源:shpterbi.cpp

示例2: animateExplosion

void TauMCTorpedo::animateExplosion()
{
	STACKTRACE;
	if (exploded) return;
	exploded = true;
	if (old_range < blast_range) {
		Query q;
		double r, d;
		for (q.begin(this, OBJECT_LAYERS, blast_range); q.currento; q.next()) {
			if (!q.current->isObject())
				continue;
			r = distance(q.currento) / blast_range;
			if (r > 1)
				r = 1;
			d = blast_damage * (1 - r*r);
			//r = sqrt(r);
			//dam = (int)ceil(d * (1-r));
			//ddam = (int)ceil(d * r);
			//q.currento->handle_damage(this, dam, ddam);
			q.currento->handle_damage(this, d, 0);
		}
		explosionSprite     = data->spriteWeaponExplosion;
		damage_factor = blast_damage;
		explosionFrameCount = 10;
		explosionFrameSize  = 50;
	}
	HomingMissile::animateExplosion();
}
开发者ID:Yurand,项目名称:tw-light,代码行数:28,代码来源:shptaumc.cpp

示例3: distance

int EarthlingCruiserMk3::activate_special()
{
	STACKTRACE;
	bool fire = false;;
	SpaceObject *o;
	double rng = 1e40;
	SpaceObject *tgt = NULL;

								 //!!!
	pos -= unit_vector(angle) * 6;
	Query q;
	for (q.begin(this, bit(LAYER_SHIPS) + bit(LAYER_SHOTS) + bit(LAYER_SPECIAL) +
	bit(LAYER_CBODIES), specialRange); q.current; q.next()) {
		o = q.currento;
		if (!o->isInvisible() && !o->sameTeam(this) && (o->collide_flag_anyone&bit(LAYER_LINES))
		&& (distance(o) < rng)) {
			tgt = o;
			rng = distance(o);
		}
	}
	q.end();
								 //!!!
	pos += unit_vector(angle) * 6;

	if (tgt) {
		game->add(new EarthlingCruiserMk3Beam(this, Vector2(0,-6), specialRange,
			specialDamage, specialDamageShots, specialFrames, tgt));
		play_sound(data->sampleSpecial[0]);
		fire = true;
	}

	return(fire);
}
开发者ID:argarak,项目名称:tw-light,代码行数:33,代码来源:shpearc3.cpp

示例4: PointLaser

int EarthlingCruiser2::activate_special()
{
	STACKTRACE;
	int fire = FALSE;
	SpaceObject *o;

	Query q;
	for (q.begin(this, bit(LAYER_SHIPS) + bit(LAYER_SHOTS) + bit(LAYER_SPECIAL) +
	bit(LAYER_CBODIES), specialRange); q.current; q.next()) {
		o = q.currento;
		if (!o->isInvisible() && !o->sameTeam(this) && (o->collide_flag_anyone&bit(LAYER_LINES))) {
			SpaceLocation *l = new PointLaser(this, pallete_color[specialColor], 1,
				specialFrames, this, o, Vector2(0.0,0.0));
			add(l);
			if (l->exists()) {
				fire = TRUE;
				l->set_depth(LAYER_EXPLOSIONS);
			}
		}
	}
	q.end();
	if (fire) sound.play((SAMPLE *)(melee[MELEE_BOOM + 0].dat));

	return(fire);
}
开发者ID:argarak,项目名称:tw-light,代码行数:25,代码来源:shpearc2.cpp

示例5: calculate

void GobPlanet::calculate ()
{
	STACKTRACE;
	SpaceObject::calculate();
	SpaceObject *o;
	Query a;
	a.begin(this, OBJECT_LAYERS, gravity_range);
	for (;a.currento;a.next()) {
		o = a.currento;
		if (o->mass > 0) {
			bool roswell = false;
			for (int i = 0; i < gobgame->gobplayers; i++) {
				if (o->ship == gobgame->gobplayer[i]->ship && gobgame->gobplayer[i]->upgrade_list[UpgradeIndex::roswelldevice]->num)
					roswell = true;
			}
			if (roswell) continue;
			double r = distance(o);
			if (r < gravity_mindist) r = gravity_mindist;
			double sr = 1;
			//gravity_power rounded up here
			if (gravity_power < 0) {
				r /= 40 * 5;
				for (int i = 0; i < -gravity_power; i += 1) sr *= r;
				o->accelerate(this, trajectory_angle(o) + PI, frame_time * gravity_force / sr, MAX_SPEED);
			} else {
				r = 1 - r/gravity_range;
				for (int i = 0; i < gravity_power; i += 1) sr *= r;
				o->accelerate(this, trajectory_angle(o) + PI, frame_time * gravity_force * sr, MAX_SPEED);
			}
		}
	}
}
开发者ID:argarak,项目名称:tw-light,代码行数:32,代码来源:ggob.cpp

示例6: collect_resources

void TeronDrone::collect_resources()
{
	STACKTRACE;
	if ( !ship ) {
		assist_building();
		if ( target ) return;
	}
	SpaceObject* ast = NULL;
	double d = TERON_DRONE_SIGHT_RANGE;
	Query q;
	for( q.begin( this, bit(LAYER_CBODIES), TERON_DRONE_SIGHT_RANGE ); q.currento; q.next() ) {
		if ( q.currento->isAsteroid() ) {
			double i = distance( q.currento );
			if ( i < d ) {
				ast = q.currento;
				d = i;
			}
		}
	}
	q.end();
	if ( ast ) {
		control->target = ast;
		target = ast;

		if ( goal != collect ) roger();
		goal = collect;
		if ( docked ) leave_dock();
	}
}
开发者ID:Yurand,项目名称:tw-light,代码行数:29,代码来源:shpterbi.cpp

示例7: calculate

void DaktaklakpakMine::calculate()

{
  AnimatedShot::calculate();
  if (!mineactive) {
    mineArming -= frame_time;
    if (mineArming <= 0) {
      mineactive = TRUE;
      v = 0;
      vel = 0;
      }
    }
  else {
    SpaceObject *o, *t = NULL;
    double oldrange = 999999;
    Query a;
    for (a.begin(this, bit(LAYER_SHIPS),(missileRange *.9));
           a.current; a.next()) {
		o = a.currento;
		if (!o->sameTeam(this) && (distance(o) < oldrange) && !(o->isAsteroid() || o->isPlanet())) {
			t = o;
			oldrange = distance(o);
			}
		}
    if (t) {
      add(new Missile(this,0,(trajectory_angle(t)),
        missileVelocity,missileDamage,missileRange,missileArmour,
        this,data->spriteExtra));
      play_sound2(data->sampleExtra[0]);
      destroy();
    }
  }
}
开发者ID:Yurand,项目名称:tw-light,代码行数:33,代码来源:shpdakvi.cpp

示例8: fire_def_shot

int VelronCruiser::fire_def_shot(double lowAngle, double highAngle, double defaultAngle)
{
	STACKTRACE;
	SpaceObject *o;
	double distance2, bestDistance2 = 99999999;
	double angleShift, relativeAngle;
	double firingAngle = defaultAngle;

	angleShift = ((double)(random()%2001-1000)/1000.0) * specialLaunchAngleDeflectionRange;

	Query a;
	for (a.begin(this, OBJECT_LAYERS, specialRange); a.current; a.next()) {
		o = a.currento;
		if ( (!o->isInvisible()) && !o->sameTeam(this)
		&& (o->collide_flag_anyone & bit(LAYER_SHOTS))) {
			distance2 = distance(o); relativeAngle = get_aim(o, lowAngle, highAngle);
			if ((distance2 < bestDistance2) && (relativeAngle > -1000)) {
				bestDistance2 = distance2;
				firingAngle = relativeAngle;
			}
		}
	}

	add(new VelronCrDefShot(this, 0.0, 0.0, normalize(angle + firingAngle + angleShift, PI2), specialVelocity,
		specialDamage, specialRange, specialArmour, data->spriteSpecial, specialRelativity));

	return(TRUE);
}
开发者ID:Yurand,项目名称:tw-light,代码行数:28,代码来源:shpvelcr.cpp

示例9: calculate

void TauMCMissile::calculate()
{
	STACKTRACE;
	Missile::calculate();
	if (state == 0) return;
	if (target)
		if ((!target->exists()) || (fabs(get_aim(target)) > track_angle))
			target = NULL;

	if (!target) {
		Query q;
		double a_a, a0 = -1e20;
		for (q.begin(this, OBJECT_LAYERS, range - d); q.currento; q.next()) {
			if (!q.current->isObject())
				continue;
			if ( (!q.currento->sameTeam(this)) && (q.currento->collide_flag_anyone&bit(layer))
			&& !q.currento->isPlanet() ) {
				a_a = fabs(get_aim(q.currento));
				if (a_a < 0) continue;
				if (a_a < track_angle) {
					a_a = (track_angle - a_a) * ((range - d) - distance(q.currento)) *
						(1 + (q.currento->isShip()?w_ship:0) + (q.currento->isShot()?w_shot:0) );
					if (a_a > a0) {
						target = q.currento;
						a0 = a_a;
					}
				}
			}
		}
	}

	if (target && !target->isInvisible()) {
		double d_a = get_aim(target);
		double ta = turn_rate * frame_time;
		if (fabs(d_a) < ta) ta = fabs(d_a);
		if (d_a > 0) turn_step += ta;
		else turn_step -= ta;
		while(fabs(turn_step) > 5.625/2) {
			if (turn_step < 0.0) {
				angle -= 5.625;
				turn_step += 5.625;
			}
			else if (turn_step > 0.0) {
				angle += 5.625;
				turn_step -= 5.625;
			}
		}
		angle = normalize(angle, 360);
	}

	// ?
	//	sprite_index = (int)(angle / 5.625) + 16;
	//	sprite_index &= 63;
	sprite_index = get_index(angle);

	//vx = v * cos(angle * ANGLE_RATIO);
	//vy = v * sin(angle * ANGLE_RATIO);
	vel = v * unit_vector(angle);
}
开发者ID:Yurand,项目名称:tw-light,代码行数:59,代码来源:shptaumc.cpp

示例10: rotate

void EarthlingCruiserMk3Beam::calculate()
{
	STACKTRACE;
	if (!(lpos && lpos->exists())) {
		lpos = 0;
		state = 0;
	}

	if ((frame < frame_count) && (lpos && lpos->exists())) {
		pos = lpos->normal_pos() + rotate(rel_pos, lpos->get_angle() - PI/2);
		vel = lpos->get_vel();
		SpaceLine::calculate();
		frame += frame_time;
	}
	else
		state = 0;

	if ((!target) && (switch_counter <= 0)) {
		SpaceObject *o;
		double rng = 1e40;
		SpaceObject *tgt = NULL;
		Query a;
		for (a.begin(this, bit(LAYER_SHIPS) + bit(LAYER_SHOTS) + bit(LAYER_SPECIAL) +
		bit(LAYER_CBODIES), base_length); a.current; a.next()) {
			o = a.currento;
			if (!o->isInvisible() && !o->sameTeam(this) && (o->collide_flag_anyone&bit(LAYER_LINES))
			&& (distance(o) < rng)) {
				tgt = o;
				rng = distance(o);
			}
		}
		if (tgt) {
			target = tgt;
			//			switch_counter = 55;
			got_spark = false;
		}
	}

	if (target && (distance(target) <= base_length)) {
		length = base_length;
		if (target->exists() && canCollide(target) && target->canCollide(this)) {
			angle = trajectory_angle(target);
		}
		if (!target->exists()) target = NULL;
	} else {
		target = NULL;
		if (switch_counter <= 0)
			//			die();
			length = 0;
		else
			switch_counter -= frame_time;
	}

	color = tw_makecol(100+tw_random()%105,100+tw_random()%105,255);
}
开发者ID:argarak,项目名称:tw-light,代码行数:55,代码来源:shpearc3.cpp

示例11: calculate

void KoloryFlamer :: calculate ()
{

    // check if the weapons exist
    weapon1 = flamer1 && flamer1->exists();
    weapon2 = flamer2 && flamer2->exists();

    // update the flamer pointers
    if (!weapon1)   flamer1 = 0;
    if (!weapon2)   flamer2 = 0;

    flame_active = weapon1 | weapon2;

    Ship::calculate();

    // regardless of whether the flames are activated or not:
    if ( this->fire_special ) {	 // DEFENSIVE MODE

        //		double HalfTime = 1000.0 * 0.5;	// 0.5 second to half the speed.
        // is nearly 1
        slowdownfactor = exp(-frame_time*1E-3 / specialHalfTime);

    } else {
        slowdownfactor = 1.0;
    }

    int layers = bit(LAYER_SHIPS) + bit(LAYER_SHOTS) + bit(LAYER_SPECIAL) +
                 bit(LAYER_CBODIES);
    double passiveRange = 1000.0;// outside this area, gravity doesn't do anything

    Query a;
    for (a.begin(this, layers, passiveRange); a.current; a.next()) {
        if (!a.current->isObject())
            continue;
        SpaceObject *o = a.currento;
        if (!(o->isPlanet()) && o != ship ) {

            // the special introduces drag around the ship, depending on distance

            o->vel *= slowdownfactor;

            if ( o->isShot() ) { // shot/missiles/homing-missiles have a different existtime/physics
                Shot *s = ((Shot*)o);
                double timeleft = (s->range - s->d) / s->v;
                s->v *= slowdownfactor;
                // express in lifetime instead of range
                s->range = s->d + s->v * timeleft;
            }

        }
    }

}
开发者ID:argarak,项目名称:tw-light,代码行数:53,代码来源:shpkolfl.cpp

示例12: calculate

void JurgathaPortal::calculate()
{
	STACKTRACE;
	Animation::calculate();

	Query a;

	for (a.begin(this, bit(LAYER_SHIPS) + bit(LAYER_SHOTS) + bit(LAYER_SPECIAL),
	sprite->width()/2); a.current; a.next()) {
		if (!a.currento->sameTeam(this) && !(a.currento->isAsteroid() || a.currento->isPlanet() ) ) {
			//a.currento->directDamage++;
			a.currento->handle_damage(this, 0, 1);
		}
	}
}
开发者ID:argarak,项目名称:tw-light,代码行数:15,代码来源:shpjurcu.cpp

示例13: calculate

void SpaceStation::calculate()
{
	STACKTRACE;

	//Healing beam code

	Query a;
	SpaceObject *o;
	for (a.begin(this, bit(LAYER_SHIPS), 200.); a.current; a.next()) {
		o = a.currento;
		if (!o->isInvisible()) {
			game->add(new PointLaser(this, 0x0000ffff, -1,
				10, this, o, Vector2(0.0, 10.0)));
		}
	}
}
开发者ID:Yurand,项目名称:tw-light,代码行数:16,代码来源:orbit.cpp

示例14: calculate

void BoggCenturion::calculate()
{
	STACKTRACE;
	Ship::calculate();

	if ((fire_weapon) && !( (batt < weapon_drain) || slowing_down)  ) {
		if (startup_time > 0)
			gun_speed += frame_time / (double)startup_time;
		else    gun_speed = 1.0;
	} else {
		slowing_down = true;
		gun_full_speed = false;
		delay_count = 0;
		if (slowdown_time > 0)
			gun_speed -= frame_time / (double)slowdown_time;
		else    gun_speed = 0;
	}
	if (gun_speed >= 1.0) {
		gun_full_speed = true;
		gun_speed = 1.0;
		if (delay_count < startup_delay) delay_count += frame_time;
	}
	else
	if ((gun_speed <= 0) && (slowing_down)) {
		gun_speed = 0;
		slowing_down = false;
	}
	gun_position += frame_time*gun_speed/weapon_rate;
	while (gun_position >= 1) gun_position -= 1;

	old_gun_phase = gun_phase;
	gun_phase = (int)floor(gun_position * 8);

	flame_count -= frame_time;

	Query q;
	links_num = 0;
	BoggCenturion* bro;
	for (q.begin(this, bit(LAYER_SHIPS), share_range); q.currento; q.next())
	if (q.currento->getID() == BOGEI_CENTURION_ID) {
		bro = (BoggCenturion*)q.currento;
		if (bro->exists())
			links_num += 1;
		if (links_num == 2) break;
	}

}
开发者ID:Yurand,项目名称:tw-light,代码行数:47,代码来源:shpbogce.cpp

示例15: handle_damage

int BoggCenturion::handle_damage(SpaceLocation *source, double normal, double direct)
//void BoggCenturion::handle_damage(SpaceLocation *source)
{
	STACKTRACE;
	if (source == this) {
		return Ship::handle_damage(source, normal, direct);
	}

	double tot = normal + direct;

	Query q;
	int ln = 0;
	BoggCenturion* bro;
	for (q.begin(this, bit(LAYER_SHIPS), share_range); q.currento; q.next())
	if (q.currento->getID() == BOGEI_CENTURION_ID) {
		bro = (BoggCenturion*)q.currento;
		if (bro->exists()) {
			ln += 1;
			link[ln] = bro;
		}
		if (links_num == max_links) break;
	}

	if (ln) {
		double d = tot;

		if (ln < 2)
			d *= 0.75;
		else
			d *= 0.5;

		tot = (int)floor(d);

		d -= tot;
		residual_damage += d;

		int dx = (int)floor(residual_damage);
		tot += dx;

		residual_damage -= dx;

	}

	Ship::handle_damage(source, tot);

	return 0;
}
开发者ID:Yurand,项目名称:tw-light,代码行数:47,代码来源:shpbogce.cpp


注:本文中的Query::begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。