コード例 #1
0
ファイル: main.cpp プロジェクト: chunkyan/DirectX
void 
update()
{
	
	Obstacle tmpObj = vehicle;
	tmpObj.moveObstacle();
	//MapNode *location =currMap.getNode(tmpObj.getOrigin());
	//MapNode *currLocation  =currMap.getNode(vehicle.getOrigin());


	if (processCollision(tmpObj)) //process collisions and damage taken
	{
		//make accomodations to ensure that 
 		vehicle.setSpeed(0);
		vehicle.moveObstacle();
	}


	vehicle.moveObstacle();
 	translate(0,0,vehicle.getSpeed());	

	if(activeBeam) //do not respond to events when beam is activated-drop vehicle velocity to zero
	{
        vehicle.setSpeed( -vehicle.getSpeed());
		return; 
	}

	//if (speed>0)
    if ( vehicle.getSpeed()>0 )
		vehicle.setSpeed(vehicle.getSpeed()-0.001f);
    else
		vehicle.setSpeed(0);

	//move the enemy player
	controller.advanceCharacter();
	display();
}
コード例 #2
0
ファイル: main.cpp プロジェクト: chunkyan/DirectX
void 
update()
{
	
	Obstacle tmpObj = vehicle;
	tmpObj.moveObstacle();
	//MapNode *location =currMap.getNode(tmpObj.getOrigin());
	//MapNode *currLocation  =currMap.getNode(vehicle.getOrigin());


	if (processCollision(tmpObj)) //process collisions and damage taken
	{
		//make accomodations to ensure that 
 		vehicle.setSpeed(0);
		vehicle.moveObstacle();
	}


	vehicle.moveObstacle();
 	translate(0,0,vehicle.getSpeed());	

	if(activeBeam) //do not respond to events when beam is activated-drop vehicle velocity to zero
	{
        vehicle.setSpeed( -vehicle.getSpeed());
		return; 
	}

	//if (speed>0)
    if ( vehicle.getSpeed()>0 )
		vehicle.setSpeed(vehicle.getSpeed()-0.001f);
    else
		vehicle.setSpeed(0);

	//move the enemy player
	controller.advanceCharacter();

	//if NPC is throwing snowball then handle it
	//create a snowball projectile
	if(npc.getCurrentState()==RELEASE_SNOWBALL)
	{
		Snowball *newSnowball = new Snowball( SNOWBALLID,
											npc.getOrigin(), //startPoint
											vehicle.getOrigin(),// endPoint
											npc.getSnowRadius(),
											snowballSpeed, //speed at which the snowball flies through the air
											minCoords, //the coords that the snowball will crash and dissolve
											maxCoords,
											snowballDamage,
											snowballGravity,
											snowballAirFriction,
											textures[FLOORID]
											); 


		projectiles.push_back(newSnowball);
	}

	//manage snowballs and the damage inflicted on the vehicle
	advanceProjectiles();

	display();
}