Beispiel #1
0
/*===========================================================================*/
void LineObject::deepCopy( const LineObject& object )
{
    BaseClass::deepCopy( object );
    m_line_type = object.lineType();
    m_color_type = object.colorType();
    m_connections = object.connections().clone();
    m_sizes = object.sizes().clone();
}
void CCircuitView::DrawImage(CDC *pDC)
{
	CPaintDC dc(this); // device context for painting
	CLogicSimulatorDoc *pDoc = (CLogicSimulatorDoc *)GetDocument();
	Gdiplus::Graphics graphics(pDC->m_hDC);
	Gdiplus::Pen P(Gdiplus::Color(0, 0, 0), 2);
	CPoint pos;			//ÇöÀç ¸¶¿ì½º Æ÷Áö¼Ç

	GetCursorPos(&pos);
	ScreenToClient(&pos);

	CRect rect;
	GetClientRect(&rect);


	for (int i = 0; i < pDoc->currBox->logicInfo.size(); i++)
	{
		pDoc->currBox->logicInfo.at(i)->draw_main(&graphics);
		//¼±Åà ‰ç´Ù¸é Ç¥½ÃÇØÁÜ
		pDoc->currBox->logicInfo.at(i)->drawLine(&graphics);
		if (pDoc->currBox->logicInfo.at(i)->isSelected)
			pDoc->currBox->logicInfo.at(i)->showSelected(&graphics);
		if (pDoc->currBox->logicInfo.at(i)->label != "") {
			pDoc->currBox->logicInfo.at(i)->showLabel(&graphics);
		}
	}

	//ÇöÀç ¸Þ´º¿¡¼­ ¾ÆÀÌÅÛ ¼±ÅÃÇÑ »óŶó¸é shadowing ±×¸®±â
	if (pDoc->isSelected) {
		Gdiplus::Pen DP(Gdiplus::Color(255, 255, 255), 2); //Dummy Pen 
		pDoc->currBox->temp->set_outputCoord(dec_x, dec_y);
		pDoc->currBox->temp->draw_shadow(&graphics, &DP);
	}

	//ÇöÀç ¸¶¿ì½º°¡ À§Ä¡ÇÑ ÀÚ¸®°¡ ºÐ±â (¶Ç´Â ¼±±×¸®±â) °¡´ÉÇÑ Á¡À̶ó¸é µ¿±×¶ó¹Ì Ç¥½Ã
	P.SetColor(Gdiplus::Color(20, 20, 250));
	if (pDoc->currBox->CanBeDivided)
		graphics.DrawArc(&P, dec_x - 5, dec_y - 5, 10, 10, 0, 360);
	P.SetColor(Gdiplus::Color(0, 0, 0));

	for (int i = 0; i < pDoc->currBox->lines.size(); i++)
	{
		LineObject* tempLine = pDoc->currBox->lines.at(i);
		tempLine->draw_main(&graphics);
		if (tempLine->isSelected)
			tempLine->draw_showSelected(&graphics);
	}
}
Beispiel #3
0
void ColoredCubeApp::initApp()
{
	D3DApp::initApp();
	
	line1.init(md3dDevice, 10.0f, GREEN);
	line2.init(md3dDevice, 10.0f, BLUE);
	line3.init(md3dDevice, 10.0f, RED);

	xLine.init(&line1, Vector3(0,0,0), 5);
	xLine.setPosition(Vector3(0,0,0));
	yLine.init(&line2, Vector3(0,0,0), 5);
	yLine.setPosition(Vector3(0,0,0));
	yLine.setRotationZ(ToRadian(90));
	zLine.init(&line3, Vector3(0,0,0), 5);
	zLine.setPosition(Vector3(0,0,0));
	zLine.setRotationY(ToRadian(90));

	quad1.init(md3dDevice, 50, CYAN);
	quad1.setPosition(Vector3(0,-5,0));

	quad2.init(md3dDevice, 50, RED);
	quad2.setPosition(Vector3(0,5,0));

	quad3.init(md3dDevice, 50, BEACH_SAND);
	quad3.setPosition(Vector3(5,5,0));
	quad3.setRotXAngle(ToRadian(90));
	quad3.setRotYAngle(ToRadian(90));

	quad4.init(md3dDevice, 50, BEACH_SAND);
	quad4.setPosition(Vector3(-5,5,0));
	quad4.setRotXAngle(ToRadian(90));
	quad4.setRotYAngle(ToRadian(90));

	quad4.init(md3dDevice, 50, BEACH_SAND);
	quad4.setPosition(Vector3(-5,5,0));
	quad4.setRotXAngle(ToRadian(90));

	quad5.init(md3dDevice, 50, DARKBROWN);
	quad5.setPosition(Vector3(0,0,-7));
	quad5.setRotXAngle(ToRadian(90));

	for(int i = 0; i < WALL_SIZE; ++i) {
		wall[i].init(md3dDevice, 1, GREEN);
		wall[i].setPosition(Vector3((rand() % MAX_RADIUS) - (MAX_RADIUS / 2), (rand() % MAX_RADIUS) - (MAX_RADIUS / 2), -6));
		wall[i].setRotXAngle(ToRadian(90));
		wall[i].setRotZAngle(ToRadian(45));
	}

	buildFX();
	buildVertexLayouts();

}
Beispiel #4
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);
}
Beispiel #5
0
void ColoredCubeApp::drawScene()
{
	D3DApp::drawScene();

	// Restore default states, input layout and primitive topology 
	// because mFont->DrawText changes them.  Note that we can 
	// restore the default states by passing null.
	md3dDevice->OMSetDepthStencilState(0, 0);
	float blendFactors[] = {0.0f, 0.0f, 0.0f, 0.0f};
	md3dDevice->OMSetBlendState(0, blendFactors, 0xffffffff);
    md3dDevice->IASetInputLayout(mVertexLayout);

	// set some variables for the shader
	int foo[1];
	foo[0] = 0;
	// set the point to the shader technique
	D3D10_TECHNIQUE_DESC techDesc;
	mTech->GetDesc(&techDesc);

	//setting the color flip variable in the shader
	mfxFLIPVar->SetRawValue(&foo[0], 0, sizeof(int));

	//draw the lines
	mWVP = xLine.getWorldMatrix()*mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
	xLine.setMTech(mTech);
	xLine.draw();
	
	mWVP = yLine.getWorldMatrix() *mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
	yLine.setMTech(mTech);
	yLine.draw();

	mWVP = zLine.getWorldMatrix() *mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
	zLine.setMTech(mTech);
	zLine.draw();

	//draw the quad using the "old" method
	//compare how messy this is compared to the objectified geometry classes
	mWVP = quad1.getWorld()*mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
    mTech->GetDesc( &techDesc );
	for(UINT p = 0; p < techDesc.Passes; ++p)
    {
        mTech->GetPassByIndex( p )->Apply(0);
       quad1.draw();
    }

	mWVP = quad2.getWorld()*mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
    mTech->GetDesc( &techDesc );
	for(UINT p = 0; p < techDesc.Passes; ++p)
    {
        mTech->GetPassByIndex( p )->Apply(0);
       quad2.draw();
    }

	mWVP = quad3.getWorld()*mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
    mTech->GetDesc( &techDesc );
	for(UINT p = 0; p < techDesc.Passes; ++p)
    {
        mTech->GetPassByIndex( p )->Apply(0);
       quad3.draw();
    }

	mWVP = quad4.getWorld()*mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
    mTech->GetDesc( &techDesc );
	for(UINT p = 0; p < techDesc.Passes; ++p)
    {
        mTech->GetPassByIndex( p )->Apply(0);
       quad4.draw();
    }

	mWVP = quad5.getWorld()*mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
    mTech->GetDesc( &techDesc );
	for(UINT p = 0; p < techDesc.Passes; ++p)
    {
        mTech->GetPassByIndex( p )->Apply(0);
       quad5.draw();
    }

	for(int i = 0; i < WALL_SIZE; ++i) {
		mWVP = wall[i].getWorld()*mView*mProj;
		mfxWVPVar->SetMatrix((float*)&mWVP);
		mTech->GetDesc( &techDesc );
		for(UINT p = 0; p < techDesc.Passes; ++p)
		{
			mTech->GetPassByIndex( p )->Apply(0);
		   wall[i].draw();
		}
	}

	// We specify DT_NOCLIP, so we do not care about width/height of the rect.
	RECT R = {5, 5, 0, 0};
	mFont->DrawText(0, mFrameStats.c_str(), -1, &R, DT_NOCLIP, BLACK);
	mSwapChain->Present(0, 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();
}
void ColoredCubeApp::initApp()
{
	D3DApp::initApp();
	
	audio->playCue(MAIN_TRACK);

	srand(time(0));

	left = Vector3(1,0,0);
	right = Vector3(-1,0,0);
	forward = Vector3(0,0,-1);
	back = Vector3(0,0,1);
	up = Vector3(0,1,0);
	down = Vector3(0,-1,0);
	zero = Vector3(0,0,0);
	
	whiteBox.init(md3dDevice, 1.0f, WHITE);
	redBox.init(md3dDevice, 1.0f, RED);
	blueBox.init(md3dDevice, 1.0f, BLUE);
	greenBox.init(md3dDevice, 1.0f, GREEN);
	crimBox.init(md3dDevice, 0.8f, CRIMSON);
	dRedBox.init(md3dDevice, 0.8f, DARKRED);
	dBlueBox.init(md3dDevice, 0.25f, DARKBLUE);

	line.init(md3dDevice, 10.0f, GREEN);

	////// New Stuff added by Steve //////
	gLine.init(md3dDevice, 10.0f, GREEN);
	rLine.init(md3dDevice, 10.0f, RED);
	bLine.init(md3dDevice, 10.0f, BLUE);
	xLine.init(&rLine, Vector3(0,0,0), 10);
	xLine.setPosition(Vector3(0,0,0));
	yLine.init(&gLine, Vector3(0,0,0), 10);
	yLine.setPosition(Vector3(0,0,0));
	yLine.setRotationZ(ToRadian(90));
	zLine.init(&bLine, Vector3(0,0,0), 10);
	zLine.setPosition(Vector3(0,0,0));
	zLine.setRotationY(ToRadian(90));
	numberOfObstacles = 50;
	float obstacleScale = 2.5f;
	float playerScale = 2.67f;
	Vector3 oScale(obstacleScale, obstacleScale, obstacleScale);
	Vector3 pScale(playerScale, playerScale, playerScale);
	playerBox.init(md3dDevice, playerScale, WHITE);
	player.init(&playerBox, sqrt(playerScale * 2.0f), Vector3(0, 2, 0), Vector3(0, 0, 0), 10, pScale, audio);
	player.linkInput(input);

	int posZ = 0;
	int posX = 0;
	int chance = 0;
	int r = 0;
	float floorSpeed = floor.getSpeed();
	for (int i=0; i<numberOfObstacles; ++i)
	{	
		Box* box = new Box();
		box->init(md3dDevice, obstacleScale, GREEN);
		obstacleBoxes.push_back(box);
		Obstacle o;
		o.init(box, sqrt(5.0f), Vector3(0,0,200), Vector3(0,0,-1), 0, Vector3(oScale));
		o.setInActive();
		obstacles.push_back(o);
	}
	///Set obstacle cluster variables
	clusterSize = 1;
	clusterSizeVariation = 3;
	clusterSeparation = 100;
	cubeSeparation = 30;
	lineJiggle = 3;
	cubeJiggle = 3;
	clusterJiggle = 10;
	floorMovement = 0.0f;

	//Other floor variables
	floorClusterCounter = 0;
	floorClusterThreshold = 7;
	floorSpeedIncrease = 5;

	//New spectrum HUD by Andy
	specHudBox[0].init(md3dDevice, .5f, 1.0f, 1.0f, RED, YELLOW);
	specHudBox[1].init(md3dDevice, .5f, 1.0f, 1.0f, YELLOW, GREEN);
	specHudBox[2].init(md3dDevice, .5f, 1.0f, 1.0f, GREEN, CYAN);
	specHudBox[3].init(md3dDevice, .5f, 1.0f, 1.0f, CYAN, BLUE);
	specHudBox[4].init(md3dDevice, .5f, 1.0f, 1.0f, BLUE, MAGENTA);
	specHudBox[5].init(md3dDevice, .5f, 1.0f, 1.0f, MAGENTA, RED);
	cursorBox.init(md3dDevice, .15f, 1.0f, .75f, BLACK, BLACK);

	Vector3 specPos = Vector3(11.0f, 25.0f, -5.0f);
	spectrum[0].init(&specHudBox[0], 1.0f,specPos + Vector3(0.0f,0.0f,0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));
	spectrum[1].init(&specHudBox[1], 1.0f,specPos + Vector3(2.0f,0.0f,0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));
	spectrum[2].init(&specHudBox[2], 1.0f,specPos + Vector3(4.0f,0.0f,0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));
	spectrum[3].init(&specHudBox[3], 1.0f,specPos + Vector3(6.0f,0.0f,0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));
	spectrum[4].init(&specHudBox[4], 1.0f,specPos + Vector3(8.0f,0.0f,0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));
	spectrum[5].init(&specHudBox[5], 1.0f,specPos + Vector3(10.0f,0.0f,0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));
	cursor.init(&cursorBox,1.0f,specPos + Vector3(-.80f, -1.0f, 0.0f), Vector3(0.0f,0.0f,0.0f), 0, Vector3(0.0f,0.0f,0.0f));


	gameObject1.init(&whiteBox, sqrt(2.0f), Vector3(-10,0,0), Vector3(0,0,0), 0,Vector3(2,2,2));
	gameObject2.init(&redBox, sqrt(2.0f), Vector3(4,0,0), Vector3(0,0,0), 0,Vector3(2,2,2));
	gameObject3.init(&redBox, sqrt(2.0f), Vector3(-4,0,0), Vector3(0,0,0), 0,Vector3(2,2,2));

	floor.init(md3dDevice);

	gameOver = false;
	activeMessage = false;
	messageTimer = 0.0f;

	//init lights - using pointlights
	lightType = 1;
	numberOfLights = 1;
	for (int i=0; i<numberOfLights; ++i)
	{
		Light l;
		l.pos = Vector3(0, 50, -17);
		l.ambient = Color(0.67f, 0.67f, 0.67f);
		l.diffuse = Color(1.0f, 1.0f, 1.0f);
		l.specular = Color(1.0f, 1.0f, 1.0f);
		l.att.x = 1.5f;
		l.att.y = 0.0f;
		l.att.z = 0.0f;
		l.range = 97.0f;
		lights.push_back(l);
	}


	buildFX();
	buildVertexLayouts();

}
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
}
void ColoredCubeApp::initApp()
{
	D3DApp::initApp();
#pragma region Base object initialization
	mBox.init(md3dDevice, 1.0f, WHITE);
	tealBox.init(md3dDevice, 1.0f, colorNS::TEAL);
	brick.init(md3dDevice, 1.0f, DARKBROWN);
	camBox.init(md3dDevice, 1.0f, BLACK);
	bulletBox.init(md3dDevice, 0.5f, BEACH_SAND);
	eBulletBox.init(md3dDevice, 0.5f, RED);
	maroonBox.init(md3dDevice, 10000, colorNS::MAROON);
	//redBox.init(md3dDevice, 0.00001f, RED);
	yellowGreenBox.init(md3dDevice, 1.f, LIGHT_YELLOW_GREEN);
	goldBox.init(md3dDevice, 1.0f, YELLOW);
	blueBox.init(md3dDevice, 2.0f, BLUE);
	rLine.init(md3dDevice, 10.0f, RED);
	bLine.init(md3dDevice, 10.0f, BLACK);
	gLine.init(md3dDevice, 10.0f, GREEN);

	xLine.init(&rLine, Vector3(0,0,0), 5);
	xLine.setPosition(Vector3(0,0,0));
	yLine.init(&bLine, Vector3(0,0,0), 5);
	yLine.setPosition(Vector3(0,0,0));
	yLine.setRotationZ(ToRadian(90));
	zLine.init(&gLine, Vector3(0,0,0), 5);
	zLine.setPosition(Vector3(0,0,0));
	zLine.setRotationY(ToRadian(90));

	for (int i = 0; i < gameNS::NUM_BULLETS; i++) {
		pBullets.push_back(new Bullet());
		pBullets[i]->init(&bulletBox, 2.0f, Vector3(0,0,0), Vector3(0,0,0), 0, 1);
	}
	for(int j=0; j<gameNS::NUM_CAMS; j++){
		for (int i = 0; i < gameNS::NUM_BULLETS; i++) {
			enBullets[j].push_back(new Bullet());
			enBullets[j][i]->init(&eBulletBox, 2.0f, Vector3(0,0,0), Vector3(0,0,0), 0, 1);
		}
		enemyTimer[j]= 0;
	}

	for (int i = 0; i < gameNS::NUM_RAGE_PICKUPS; i++) {
		ragePickups.push_back(GameObject());
	}

	
	ragePickups[0].init(&tealBox, 2.0f, Vector3(-35,0,95), Vector3(0,0,0),0,1);
	ragePickups[1].init(&tealBox, 2.0f, Vector3(6,0,-80), Vector3(0,0,0),0,1);
	ragePickups[2].init(&tealBox, 2.0f, Vector3(-84,0,-56), Vector3(0,0,0),0,1);
	ragePickups[3].init(&tealBox, 2.0f, Vector3(10,0,80), Vector3(0,0,0),0,1);
	

	//floor.init(&yellowGreenBox, sqrt(2.0), Vector3(-5,-0.02,-5), Vector3(0,0,0), 0, 1);
	floor.init(&yellowGreenBox, 2.0f, Vector3(0,-1.5f,0), 1.0f, 100, 0.01, 100);
	player.init(&mBox, pBullets, sqrt(2.0f), Vector3(-90,0,85), Vector3(0,0,0), 0, 1);
	
	superLowFloorOffInTheDistanceUnderTheScene.init(&maroonBox, 2.0f, Vector3(0,-10.0f,0), Vector3(0,0,0), 0, 100000);

//				   geom,  rad,  position,			sc,	w,  h,  d
	walls[0].init(&brick, 2.0f, Vector3(0, 0, 100),	1, 100, 10, 1);
	walls[1].init(&brick, 2.0f, Vector3(0, 0, -100),1, 100, 10, 1);
	walls[2].init(&brick, 2.0f, Vector3(100, 0, 0), 1, 1,	10, 100);
	walls[3].init(&brick, 2.0f, Vector3(-100, 0, 0),1, 1,	2, 100);
	walls[4].init(&brick, 2.0f, Vector3(-80,0,75),	1, 1,	2,	25);
	walls[5].init(&brick, 2.0f, Vector3(-80,0,25),	1, 20,	2,	1);
	walls[6].init(&brick, 2.0f, Vector3(-53.5,0,0),	1, 46.5,2,	1);
	walls[7].init(&brick, 2.0f, Vector3(-30,0, 25),	1, 1,	2,  25);
	walls[8].init(&brick, 2.0f, Vector3(-10,0, 50),	1, 10,	2,  1);
	walls[9].init(&brick, 2.0f, Vector3(0,0, 74),	1, 1,	2,  26);
	walls[10].init(&brick, 2.0f, Vector3(-5,0, 12),	1, 25,	2,  1);
	walls[11].init(&brick, 2.0f, Vector3(28.5,0, 0),1,21.5,2,  1);
	walls[12].init(&brick, 2.0f, Vector3(0.5,0, -37), 1, 1,	2,  37);
	walls[13].init(&brick, 2.0f, Vector3(20,0, 40), 1, 1,	2,  40);
	walls[14].init(&brick, 2.0f, Vector3(50,0, 80), 1, 30,	2,  1);
	walls[15].init(&brick, 2.0f, Vector3(75,0, 60), 1, 25,	2,  1);
	walls[16].init(&brick, 2.0f, Vector3(50,0, 40), 1, 30,	2,  1);
	walls[17].init(&brick, 2.0f, Vector3(75,0, 20), 1, 25,	2,  1);
	walls[18].init(&brick, 2.0f, Vector3(50,0, 10), 1, 30,	2,  1);
	walls[19].init(&brick, 2.0f, Vector3(80,0, 0), 1, 20,	2,  1);
	walls[20].init(&brick, 2.0f, Vector3(48.5,0, -30), 1, 1,	2,  30);
	walls[21].init(&brick, 2.0f, Vector3(60,0, -22.5), 1, 1,	2,  23);
	walls[22].init(&brick, 2.0f, Vector3(60, 0, -60), 1, 11.5,2,  1);
	walls[23].init(&brick, 2.0f, Vector3(-15, 0, -75), 1, 1, 2, 25);
	walls[24].init(&brick, 2.0f, Vector3(-40, 0, -50), 1, 40, 2, 1);
	walls[25].init(&brick, 2.0f, Vector3(-30, 0, -35), 1, 20, 2, 1);
	walls[26].init(&brick, 2.0f, Vector3(-30, 0, -15), 1, 20, 2, 1);
	walls[27].init(&brick, 2.0f, Vector3(-30, 0, -8), 1, 1, 2, 8);
	walls[28].init(&brick, 2.0f, Vector3(-30, 0, -42), 1, 1, 2, 8);
	walls[29].init(&brick, 2.0f, Vector3(-60, 0, -31), 1, 1, 2, 18);
	walls[30].init(&brick, 2.0f, Vector3(-70, 0, -31), 1, 1, 2, 18);
	walls[31].init(&brick, 2.0f, Vector3(-79, 0, -30), 1, 1, 2, 19);
	walls[32].init(&brick, 2.0f, Vector3(-79, 0, -85), 1, 1, 2, 15);
	walls[33].init(&brick, 2.0f, Vector3(-95, 0, -70), 1, 5, 2, 1);
	walls[34].init(&brick, 2.0f, Vector3(-95, 0, -30), 1, 5, 2, 1);
	walls[35].init(&brick, 2.0f, Vector3(80, 0, -25), 1, 1, 2, 25);
	walls[36].init(&brick, 2.0f, Vector3(48.5, 0, -70), 1, 1, 2, 15);
	walls[37].init(&brick, 2.0f, Vector3(29.5, 0, -85), 1, 20, 2, 1);
	walls[38].init(&brick, 2.0f, Vector3(-50, 0, 49), 1, 20, 2, 1);
	walls[39].init(&brick, 2.0f, Vector3(-50, 0, 70), 1, 20, 2, 1);
	walls[40].init(&brick, 2.0f, Vector3(-30, 0, 70), 1, 1, 2, 20);
#pragma endregion

	//for(int i=0; i<gameNS::NUM_CAMS; i++)
	//{
	//	enBullet[i].init(&eBulletBox, 2.0f, Vector3(0,0,0), Vector3(0,0,0), bulletNS::SPEED, 1);
	//	
	//}
#pragma region Camera Placement
	enemyCam[0].init(&camBox, enBullets[0], 2.0f, Vector3(-90,0,15), Vector3(0,0,0), 0, 0, 1);
	enemyCam[1].init(&camBox, enBullets[1], 2.0f, Vector3(-35,0,5), Vector3(0,0,0), 0, 0, 1);
	enemyCam[2].init(&camBox, enBullets[2], 2.0f, Vector3(-35,0,45), Vector3(0,0,0), 0, 0, 1);
	enemyCam[3].init(&camBox, enBullets[3], 2.0f, Vector3(-35,0,60), Vector3(0,0,0), 0, 0, 1);
	enemyCam[4].init(&camBox, enBullets[4], 2.0f, Vector3(-75,0,60), Vector3(0,0,0), 0, 0, 1);
	enemyCam[5].init(&camBox, enBullets[5], 2.0f, Vector3(-35,0,75), Vector3(0,0,0), 0, 0, 1);
	enemyCam[6].init(&camBox, enBullets[6], 2.0f, Vector3(-75,0,95), Vector3(0,0,0), 0, 0, 1);
	enemyCam[7].init(&camBox, enBullets[7], 2.0f, Vector3(-5,0,95), Vector3(0,0,0), 0, 0, 1);
	enemyCam[8].init(&camBox, enBullets[8], 2.0f, Vector3(-5,0,55), Vector3(0,0,0), 0, 0, 1);
	enemyCam[9].init(&camBox, enBullets[9], 2.0f, Vector3(-25,0,75), Vector3(0,0,0), 0, 0, 1);
	enemyCam[10].init(&camBox, enBullets[10], 2.0f, Vector3(15,0,16), Vector3(0,0,0), 0, 0, 1);
	enemyCam[11].init(&camBox, enBullets[11], 2.0f, Vector3(-25,0,16), Vector3(0,0,0), 0, 0, 1);
	enemyCam[12].init(&camBox, enBullets[12], 2.0f, Vector3(0,0,45), Vector3(0,0,0), 0, 0, 1);
	enemyCam[13].init(&camBox, enBullets[13], 2.0f, Vector3(10,0,75), Vector3(0,0,0), 0, 0, 1);
	enemyCam[14].init(&camBox, enBullets[14], 2.0f, Vector3(30,0,90), Vector3(0,0,0), 0, 0, 1);
	enemyCam[15].init(&camBox, enBullets[15], 2.0f, Vector3(60,0,90), Vector3(0,0,0), 0, 0, 1);
	enemyCam[16].init(&camBox, enBullets[16], 2.0f, Vector3(90,0,90), Vector3(0,0,0), 0, 0, 1);
	enemyCam[17].init(&camBox, enBullets[17], 2.0f, Vector3(30,0,70), Vector3(0,0,0), 0, 0, 1);
	enemyCam[18].init(&camBox, enBullets[18], 2.0f, Vector3(60,0,70), Vector3(0,0,0), 0, 0, 1);
	enemyCam[19].init(&camBox, enBullets[19], 2.0f, Vector3(90,0,70), Vector3(0,0,0), 0, 0, 1);
	enemyCam[20].init(&camBox, enBullets[20], 2.0f, Vector3(30,0,50), Vector3(0,0,0), 0, 0, 1);
	enemyCam[21].init(&camBox, enBullets[21], 2.0f, Vector3(60,0,50), Vector3(0,0,0), 0, 0, 1);
	enemyCam[22].init(&camBox, enBullets[22], 2.0f, Vector3(90,0,50), Vector3(0,0,0), 0, 0, 1);
	enemyCam[23].init(&camBox, enBullets[23], 2.0f, Vector3(45,0,60), Vector3(0,0,0), 0, 0, 1);
	enemyCam[24].init(&camBox, enBullets[24], 2.0f, Vector3(30,0,30), Vector3(0,0,0), 0, 0, 1);
	enemyCam[25].init(&camBox, enBullets[25], 2.0f, Vector3(60,0,30), Vector3(0,0,0), 0, 0, 1);
	enemyCam[26].init(&camBox, enBullets[26], 2.0f, Vector3(90,0,30), Vector3(0,0,0), 0, 0, 1);
	enemyCam[27].init(&camBox, enBullets[27], 2.0f, Vector3(90,0,10), Vector3(0,0,0), 0, 0, 1);
	enemyCam[28].init(&camBox, enBullets[28], 2.0f, Vector3(30,0,5), Vector3(0,0,0), 0, 0, 1);
	enemyCam[29].init(&camBox, enBullets[29], 2.0f, Vector3(70,0,-20), Vector3(0,0,0), 0, 0, 1);
	enemyCam[30].init(&camBox, enBullets[30], 2.0f, Vector3(90,0,-20), Vector3(0,0,0), 0, 0, 1);
	enemyCam[31].init(&camBox, enBullets[31], 2.0f, Vector3(90,0,-90), Vector3(0,0,0), 0, 0, 1);
	enemyCam[32].init(&camBox, enBullets[32], 2.0f, Vector3(55,0,-65), Vector3(0,0,0), 0, 0, 1);
	enemyCam[33].init(&camBox, enBullets[33], 2.0f, Vector3(30,0,-92), Vector3(0,0,0), 0, 0, 1);
	enemyCam[34].init(&camBox, enBullets[34], 2.0f, Vector3(-8,0,-60), Vector3(0,0,0), 0, 0, 1);
	enemyCam[35].init(&camBox, enBullets[35], 2.0f, Vector3(10,0,-5), Vector3(0,0,0), 0, 0, 1);
	enemyCam[36].init(&camBox, enBullets[36], 2.0f, Vector3(10,0,-25), Vector3(0,0,0), 0, 0, 1);
	enemyCam[37].init(&camBox, enBullets[37], 2.0f, Vector3(10,0,-45), Vector3(0,0,0), 0, 0, 1);
	enemyCam[38].init(&camBox, enBullets[38], 2.0f, Vector3(10,0,-65), Vector3(0,0,0), 0, 0, 1);
	enemyCam[39].init(&camBox, enBullets[39], 2.0f, Vector3(20,0,-15), Vector3(0,0,0), 0, 0, 1);
	enemyCam[40].init(&camBox, enBullets[40], 2.0f, Vector3(20,0,-35), Vector3(0,0,0), 0, 0, 1);
	enemyCam[41].init(&camBox, enBullets[41], 2.0f, Vector3(20,0,-55), Vector3(0,0,0), 0, 0, 1);
	enemyCam[42].init(&camBox, enBullets[42], 2.0f, Vector3(20,0,-75), Vector3(0,0,0), 0, 0, 1);
	enemyCam[43].init(&camBox, enBullets[43], 2.0f, Vector3(30,0,-5), Vector3(0,0,0), 0, 0, 1);
	enemyCam[44].init(&camBox, enBullets[44], 2.0f, Vector3(30,0,-25), Vector3(0,0,0), 0, 0, 1);
	enemyCam[45].init(&camBox, enBullets[45], 2.0f, Vector3(30,0,-45), Vector3(0,0,0), 0, 0, 1);
	enemyCam[46].init(&camBox, enBullets[46], 2.0f, Vector3(30,0,-65), Vector3(0,0,0), 0, 0, 1);
	enemyCam[47].init(&camBox, enBullets[47], 2.0f, Vector3(40,0,-15), Vector3(0,0,0), 0, 0, 1);
	enemyCam[48].init(&camBox, enBullets[48], 2.0f, Vector3(40,0,-35), Vector3(0,0,0), 0, 0, 1);
	enemyCam[49].init(&camBox, enBullets[49], 2.0f, Vector3(40,0,-55), Vector3(0,0,0), 0, 0, 1);
	enemyCam[50].init(&camBox, enBullets[50], 2.0f, Vector3(40,0,-75), Vector3(0,0,0), 0, 0, 1);
	enemyCam[51].init(&camBox, enBullets[51], 2.0f, Vector3(-25,0,6), Vector3(0,0,0), 0, 0, 1);
	enemyCam[52].init(&camBox, enBullets[52], 2.0f, Vector3(-25,0,-6), Vector3(0,0,0), 0, 0, 1);
	enemyCam[53].init(&camBox, enBullets[53], 2.0f, Vector3(-25,0,-43), Vector3(0,0,0), 0, 0, 1);
	enemyCam[54].init(&camBox, enBullets[54], 2.0f, Vector3(-35,0,-6), Vector3(0,0,0), 0, 0, 1);
	enemyCam[55].init(&camBox, enBullets[55], 2.0f, Vector3(-35,0,-43), Vector3(0,0,0), 0, 0, 1);
	enemyCam[56].init(&camBox, enBullets[56], 2.0f, Vector3(-50,0,-25), Vector3(0,0,0), 0, 0, 1);
	enemyCam[57].init(&camBox, enBullets[57], 2.0f, Vector3(-10,0,-25), Vector3(0,0,0), 0, 0, 1);
	enemyCam[58].init(&camBox, enBullets[58], 2.0f, Vector3(-65,0,-45), Vector3(0,0,0), 0, 0, 1);
	enemyCam[59].init(&camBox, enBullets[59], 2.0f, Vector3(-75,0,-45), Vector3(0,0,0), 0, 0, 1);
	enemyCam[60].init(&camBox, enBullets[60], 2.0f, Vector3(-95,0,-15), Vector3(0,0,0), 0, 0, 1);
	enemyCam[61].init(&camBox, enBullets[61], 2.0f, Vector3(-95,0,-50), Vector3(0,0,0), 0, 0, 1);
	enemyCam[62].init(&camBox, enBullets[62], 2.0f, Vector3(-95,0,-95), Vector3(0,0,0), 0, 0, 1);
	enemyCam[63].init(&camBox, enBullets[63], 2.0f, Vector3(-33,0,-95), Vector3(0,0,0), 0, 0, 1);
	enemyCam[64].init(&camBox, enBullets[64], 2.0f, Vector3(-46,0,-95), Vector3(0,0,0), 0, 0, 1);
	enemyCam[65].init(&camBox, enBullets[65], 2.0f, Vector3(-59,0,-95), Vector3(0,0,0), 0, 0, 1);
	enemyCam[66].init(&camBox, enBullets[66], 2.0f, Vector3(-72,0,-95), Vector3(0,0,0), 0, 0, 1);
	enemyCam[67].init(&camBox, enBullets[67], 2.0f, Vector3(-20,0,-75), Vector3(0,0,0), 0, 0, 1);
	enemyCam[68].init(&camBox, enBullets[68], 2.0f, Vector3(-33,0,-75), Vector3(0,0,0), 0, 0, 1);
	enemyCam[69].init(&camBox, enBullets[69], 2.0f, Vector3(-46,0,-75), Vector3(0,0,0), 0, 0, 1);
	enemyCam[70].init(&camBox, enBullets[70], 2.0f, Vector3(-59,0,-75), Vector3(0,0,0), 0, 0, 1);
	enemyCam[71].init(&camBox, enBullets[71], 2.0f, Vector3(-72,0,-75), Vector3(0,0,0), 0, 0, 1);
	enemyCam[72].init(&camBox, enBullets[72], 2.0f, Vector3(-20,0,-55), Vector3(0,0,0), 0, 0, 1);
	enemyCam[73].init(&camBox, enBullets[73], 2.0f, Vector3(-33,0,-55), Vector3(0,0,0), 0, 0, 1);
	enemyCam[74].init(&camBox, enBullets[74], 2.0f, Vector3(-46,0,-55), Vector3(0,0,0), 0, 0, 1);
	enemyCam[75].init(&camBox, enBullets[75], 2.0f, Vector3(-59,0,-55), Vector3(0,0,0), 0, 0, 1);
	enemyCam[76].init(&camBox, enBullets[76], 2.0f, Vector3(-72,0,-55), Vector3(0,0,0), 0, 0, 1);
	enemyCam[77].init(&blueBox, enBullets[77], 2.0f, Vector3(-20,0,-95), Vector3(0,0,0), 0, 0, 1); //dunstan will always be the last camera in the list
#pragma endregion

	for(int i=0; i<gameNS::NUM_MONEY; i++)
	{
		money[i].init(&goldBox, 2.0f, Vector3(rand()%190 - 90, 0, rand()%180 - 90), Vector3(0,0,0), 0, 1, rand()%2);
	}

	//Initializing text strings yay
	sText.addLine("WELCOME RUGGER !", 10, 10);
	sText.addLine("WASD TO MOVE", 10, 30);
	sText.addLine("ARROW KEYS TO SHOOT", 10, 50);
	sText.addLine("HOLD SHIFT TO SPRINT!", 10, 70);
	sText.addLine("GO KILL DUNSTAN FOR ME!", 10, 90);
	sText.addLine("PRESS ANY KEY TO BEGIN !", 250, 300);
	eText.addLine("CONGRATS RUGGER I WON!", 250, 300);

	shotTimer = 0;
	buildFX();
	buildVertexLayouts();
	audio->playCue(MUSIC);
}