示例#1
0
void Player::CheckCollision(Hook h[], int numHooks)
{
	
	for(int i = 0; i < numHooks; i++)
	{
		Hook tempHook = h[i];
		double dist = TrueDist(x,tempHook.getX(), z,tempHook.getZ());
		//printf ("%lf truedist  %lf radius\n", dist, tempHook.getRadius());
		if(dist < tempHook.getRadius())
		{
			//printf("Caught\n");
			caught = 1;
			h[i].catchFish();
			myHook = &(h[i]);
			break;
		}
	}

}
示例#2
0
void Player::Go(Player *P, int numplayers, const Boundary &Path, const Boundary &BLL,const Boundary &BL,const Boundary &BR,const Boundary &BRR, const Button &B, Hook h[],int numHooks)
{
	if(B.reset)
	{
		Reset();
	}

	if(caught)
	{
		Hook myHookobj = *myHook;

		y = myHookobj.getY();
		caught = myHookobj.caughtOrNot();
		
		if(!caught)
		{
			y = .5;
			z += myHookobj.getRadius()+2;
		}

	}
	else
	{
			//Does everything for the player
		//Works for every type of player. no specifications need to be given, just a lot of objects get passed in

		Input(B);//Keyboard input for all players

		//Player-Player interaction
		if(!finish)//The player hasn't finished
		{
			Race(Path);//Follow the path
			AI(P,numplayers);//Act
		}
		else
			Finished();		//Act finished
		Bounce(P,numplayers);	//Check for bounces between each player

		//Player-Env. Interaction
		DetectBoundary(BLL,BL);	//Check left boundary
		DetectBoundary(BR,BRR);	//Check right boundary
		DetectEndCond(Path);	//Check end line&beginning


	
		if(usedtobeinabound==1||inabound==1)
			MoveBound();
		else//if not in a boundary
			MoveDamp();
	
		//Combine all
		Move();
	
		//Check to see that the Players have not exicted the outer boundary
		Check(BLL, BL,Path,BR, BRR);
		CheckFinished(Path);//Check to see if the player is passed the ifinish line
		if(pt == 0)
		{
			CheckCollision(h, numHooks);
		}

	}
}