コード例 #1
0
void ColoredCubeApp::updateScene(float dt)
{
	D3DApp::updateScene(dt);
	xLine.update(dt);
	yLine.update(dt);
	zLine.update(dt);
	quad1.update(dt);
	quad2.update(dt);
	quad3.update(dt);
	quad4.update(dt);
	quad5.update(dt);

	for(int i = 0; i < WALL_SIZE; ++i) {
		wall[i].update(dt);
	}

	D3DXVECTOR3 pos(0.0f,0.0f,15.0f);
	D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
	D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
	D3DXMatrixLookAtLH(&mView, &pos, &target, &up);
}
コード例 #2
0
void ColoredCubeApp::updateScene(float dt)
{
	D3DApp::updateScene(dt);

	float gameTime = mTimer.getGameTime();


	if (gameTime > 1.0f && !gameOver)
	{
		////// New Stuff added by Steve //////
		player.move(dt);
		player.update(dt);

		//new clustered cube code
		floorMovement += floor.getSpeed() * dt;
		if (floorMovement > clusterSeparation)
		{
			floorMovement = 0.0f;
			setNewObstacleCluster();
			floorClusterCounter++;
			
		}
		if (floorClusterCounter > floorClusterThreshold)
		{
			floorClusterCounter = 0;
			floor.addSpeed((float)floorSpeedIncrease);
			clusterSeparation--;
			cubeSeparation--;
			if (cubeSeparation < 12)
				cubeSeparation = 12;
			if (clusterSeparation < cubeSeparation * (clusterSize + clusterSizeVariation / 2))
				clusterSeparation = cubeSeparation * (clusterSize + clusterSizeVariation / 2);
		}

		for (int i = 0; i < numberOfObstacles; i++) {
			obstacles[i].setSpeed(floor.getSpeed());
			float zPos = obstacles[i].getPosition().z;
			if (zPos > 100 && zPos < 130)
				for (int f=0; f<floor.size(); ++f)
				{
					if (floor.section(f).contains(Vector3(0, -2, zPos)))
					{
						DXColor compliment = floor.section(f).colorAtPoint(zPos);
						compliment.r = 1.0f - compliment.r;
						compliment.g = 1.0f - compliment.g;
						compliment.b = 1.0f - compliment.b;
						obstacles[i].setColor(compliment);
						break;
					}
				}
			obstacles[i].update(dt);
			if (player.isWithin(12.0f, &obstacles[i]))
			{
				if (player.collided(&obstacles[i]))
				{
					gameOver = true;
					audio->playCue(GAME_OVER);
				}
			}
		}

		for(int i = 0; i < 6; i++) {
			spectrum[i].update(dt);
		}

		float cursorPos = player.getWheelVal();
		cursor.setPosition(Vector3(10.2f,24.0f,-5.0f) + 2*Vector3(cursorPos, 0.0f, 0.0f));
		cursor.update(dt);


		xLine.update(dt);
		yLine.update(dt);
		zLine.update(dt);
		//////////////////////////////////////
		// Floor test code //



		/*for (int i=0; i<floor.size(); ++i)
		{
			floor[i].update(dt);
			float zPos = floor[i].getPosition().z;
			if (zPos < -50)
				floor[i].setPosition(Vector3(0, -2, zPos + floor.size() * floorSectionLength));
		}*/
		//Changes By: Daniel J. Ecker
	}
	floor.update(dt);

	

	// Build the view matrix.
	D3DXVECTOR3 pos(0.0f,45.0f,-50.0f);
	D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
	D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
	D3DXMatrixLookAtLH(&mView, &pos, &target, &up);
	input->clearAll();
}
コード例 #3
0
void ColoredCubeApp::updateScene(float dt)
{
	if(!endScreen && !startScreen)
	{
	
		if(!enemyCam[gameNS::NUM_CAMS-1].getActiveState()) endScreen = true;
	
		D3DApp::updateScene(dt);
		Vector3 oldPos = player.getPosition();

		if(input->isKeyDown(VK_UP)) player.shoot(UP);
		if(input->isKeyDown(VK_DOWN)) player.shoot(DOWN);
		if(input->isKeyDown(VK_LEFT)) player.shoot(LEFT);
		if(input->isKeyDown(VK_RIGHT)) player.shoot(RIGHT);
		if(input->isKeyDown(VK_SHIFT)) {
			player.setSpeed(40);
		}
		else player.setSpeed(20);
		player.setVelocity(moveCube() * player.getSpeed());
		player.update(dt);
	
		for (int i = 0; i < ragePickups.size(); i++) {
			if (player.collided(&ragePickups[i])) {
				ragePickups[i].setInActive();
				player.charge();
			}
			ragePickups[i].update(dt);
		}

		for(int i=0; i<gameNS::NUM_WALLS; i++)
		{
			if(player.collided(&walls[i]))
			{
				//DEBUGGING AND LEVEL LAYOUT, COMMENT THIS OUT
#ifdef DEBUGGING
				
#else
				player.setPosition(oldPos);
#endif
			}
			for (int j = 0; j < pBullets.size(); j++) {
				if (pBullets[j]->collided(&walls[i])) {
					pBullets[j]->setInActive();
					pBullets[j]->setVelocity(D3DXVECTOR3(0,0,0));
					pBullets[j]->setPosition(D3DXVECTOR3(0,0,0));
					shotTimer = 0;
				}		
			}
			for(int j=0; j<gameNS::NUM_CAMS; j++)
			{
				for(int k=0; k<enBullets[j].size(); k++)
				{
					if(enBullets[j][k]->collided(&walls[i])) 
					{
						enBullets[j][k]->setInActive();
						enBullets[j][k]->setVelocity(Vector3(0,0,0));
					}
					if(player.collided(enBullets[j][k]))
					{
						enBullets[j][k]->setInActive();
						enBullets[j][k]->setVelocity(Vector3(0,0,0));
						score--;
						audio->stopCue(OUCH1);
						audio->stopCue(OUCH2);
						audio->stopCue(SAD);
						switch(rand()%3+1){
						case 1:
							audio->playCue(OUCH1);
							break;
						case 2:
							audio->playCue(OUCH2);
							break;
						case 3:
							audio->playCue(SAD);
						}
					}
				}
			}
		}

		for(int i=0; i<gameNS::NUM_MONEY; i++)
		{
			if(player.collided(&money[i]))
			{
				money[i].setInActive();
				score += money[i].getPoints();
				audio->playCue(CASH);
			}
			money[i].update(dt);
		}
	
		floor.update(dt);
		//gameObject2.update(dt);
		//gameObject3.update(dt);
		//spinner.update(dt);
		xLine.update(dt);
		//xLine.setPosition(player.getPosition());
		yLine.update(dt);
		//yLine.setPosition(player.getPosition());
		zLine.update(dt);
		//zLine.setPosition(player.getPosition());
		//wall.update(dt);
		//quad1.update(dt);

		for(int i=0; i<gameNS::NUM_WALLS; i++)walls[i].update(dt);
		for(int i=0; i<gameNS::NUM_CAMS; i++)
		{
			for (int j = 0; j < pBullets.size(); j++) {
				if(pBullets[j]->collided(&enemyCam[i])&& enemyCam[i].getActiveState())
				{
					enemyCam[i].setInActive();
					audio->playCue(HIT);
					pBullets[j]->setInActive();
					pBullets[j]->setVelocity(D3DXVECTOR3(0,0,0));
					pBullets[j]->setPosition(D3DXVECTOR3(0,0,0));
					score++;
				}
			}
			enemyCam[i].update(dt, &player);
			enemyCam[i].shoot(&player);
			//if(!enemyCam[i].getActiveState())
			//	enemyTimer[i] = 0;
			//for(int k=0; k<enBullets[k].size(); k++)
			//{
			//	enBullets[i][k]->update(dt);
			//}
		}
		int numberInRange=0;
		for(int i=0; i<gameNS::NUM_CAMS; i++){
			if(enemyCam[i].isInRange(player.getPosition()) && enemyTimer[i] == 0 && enemyCam[i].getActiveState()){
				audio->playCue(WOOP_WOOP);
				enemyTimer[i]=1;
			}
			if(!enemyCam[i].isInRange(player.getPosition()) || !enemyCam[i].getActiveState()){
				enemyTimer[i]=0;
			}
			numberInRange+=enemyTimer[i];
		}
		if(numberInRange==0) audio->stopCue(WOOP_WOOP);
		//spinAmount += dt ;
		//if (ToRadian(spinAmount*40)>2*PI)
		//	spinAmount = 0;
		//Build the view matrix.
		//D3DXVECTOR3 pos(-100.0f,100.0f,50.0f);
		//D3DXVECTOR3 pos(-50.0f, 150.0f, 0.0f);
		//D3DXVECTOR3 target(0.0f, 0.0f, 0.0f);
		//D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
	}
	else if (startScreen)
	{
		if(input->anyKeyPressed()) startScreen = false;
	}
	else
	{
		Sleep(1000);
		if(input->anyKeyPressed())
		{
			endScreen = false;
			PostQuitMessage(0);
		}
	}
	D3DXVECTOR3 pos(player.getPosition().x - 25, player.getPosition().y + 50, player.getPosition().z);
	D3DXVECTOR3 target(player.getPosition());
	D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
	D3DXMatrixLookAtLH(&mView, &pos, &target, &up);

#pragma region first-pass cleanup
	//For the first update pass, we want to remove any money that is colliding with cameras or walls
	if(firstpass)
	{
		firstpass = false;
		for(int i=0; i<gameNS::NUM_WALLS; i++)
		{
			for(int k=0; k<gameNS::NUM_MONEY; k++)
			{
				if(money[k].getActiveState() && money[k].collided(&walls[i]))
				{
					money[k].setInActive();
				}
			}
		}
		for(int i=0; i<gameNS::NUM_CAMS; i++)
		{
			for(int k=0; k<gameNS::NUM_MONEY; k++)
			{
				if(money[k].getActiveState() && money[k].collided(&enemyCam[i]))
				{
					money[k].setInActive();
				}
			}
		}
	}
#pragma endregion
}