Beispiel #1
0
//
// WinMain
//
int WINAPI WinMain(HINSTANCE hinstance,
				   HINSTANCE prevInstance, 
				   PSTR cmdLine,
				   int showCmd)
{
	if(!d3d::InitD3D(hinstance,
		Width, Height, true, D3DDEVTYPE_HAL, &Device))
	{
		::MessageBox(0, "InitD3D() - FAILED", 0, 0);
		return 0;
	}
	HRESULT hr;
    if( FAILED( hr = sound.PrepareXACT() ) )
    {
        if( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ) )
            MessageBox( 0, "Failed to init XACT because media not found.", "XACT Tutorial", MB_OK );
        else
            MessageBox( 0, "Failed to init XACT./n(sometimes Xact like to act up the first time ran on new computers try going to the Sound.xap file in the project folder and pressing F7 then enter)", "XACT Tutorial", MB_OK );
       sound.CleanupXACT();
        return 0;
    }		
	if(!Setup())
	{
		::MessageBox(0, "Setup() - FAILED", 0, 0);
		return 0;
	}
	sound.AudioPlay(Song);
	::MessageBoxA(0, "You wake up in a field, and as you look around all you see is a scary mansion off in the distance\nYou decide to make your way towards the mansion in hopes of finding help", "Welcome", MB_OK);
	::MessageBoxA(0, "Use WSAD to move the camera around\nUse the Arrow Keys to look around", "Welcome", MB_OK);
	d3d::EnterMsgLoop( Display );
	Cleanup();
	Device->Release();
	return 0;
}
Beispiel #2
0
bool Display(float timeDelta)
{
	if( Device )
	{
		if(::GetAsyncKeyState('P') & 0x8000f)
			pause = true;
		if(::GetAsyncKeyState('W') & 0x8000f)
			TheCamera.walk(1.0 * DTime);
		if(::GetAsyncKeyState('S') & 0x8000f)
			TheCamera.walk(-1.0 * DTime);
		if(::GetAsyncKeyState('A') & 0x8000f)
			TheCamera.strafe(-1.0 * DTime);
		if(::GetAsyncKeyState('D') & 0x8000f)
			TheCamera.strafe(1.0 * DTime);
		if(::GetAsyncKeyState('F') & 0x8000f)
			TheCamera.fly(-1.0 * DTime);
		if(::GetAsyncKeyState('R') & 0x8000f)
			TheCamera.fly(1.0 * DTime);
		if(::GetAsyncKeyState(VK_UP) & 0x8000f)
			TheCamera.pitch(-.250 * DTime);
		if(::GetAsyncKeyState(VK_DOWN) & 0x8000f)
			TheCamera.pitch(.250 * DTime);
		if(::GetAsyncKeyState(VK_LEFT) & 0x8000f)
			TheCamera.yaw(-.250 * DTime);
		if(::GetAsyncKeyState(VK_RIGHT) & 0x8000f)
			TheCamera.yaw(.250 * DTime);
		if(::GetAsyncKeyState(VK_HOME) & 0x8000f)
			TheCamera.roll(.250 * DTime);
		if(::GetAsyncKeyState(VK_END) & 0x8000f)
			TheCamera.roll(-.250 * DTime);
		if(TheCamera._up.y < 0)
			TheCamera._up.y *= -1;

		Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
		Device->BeginScene();
		DrawWalls();
		D3DXMATRIX i, tripler, grow;
		D3DXMatrixIdentity(&i);
		Device->SetTransform(D3DTS_WORLD, &i);
		
		//1
		D3DXMatrixTranslation(&tripler, TigerPos.x, TigerPos.y, TigerPos.z);
		D3DXMatrixScaling(&grow, 5/sizeModifier, 5/sizeModifier, 5/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Tiger.Draw(Stone);
		//2	
		D3DXMatrixTranslation(&tripler, CastlePos.x, CastlePos.y, CastlePos.z);
		D3DXMatrixScaling(&grow, 2.5/sizeModifier, 1/sizeModifier, 2.5/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Castle.Draw(Stone);
		//3		
		D3DXMatrixTranslation(&tripler, GrenadePos.x, GrenadePos.y, GrenadePos.z);
		D3DXMatrixScaling(&grow, .1/sizeModifier, .1/sizeModifier, .1/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Grenade.Draw(Stone);
		//4
		D3DXMatrixTranslation(&tripler, ManorPos.x, ManorPos.y, ManorPos.z);
		D3DXMatrixScaling(&grow, 5000/sizeModifier, 5000/sizeModifier, 50);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Manor.Draw(Stone);
		//5		
		D3DXMatrixTranslation(&tripler, MonsterPos.x, MonsterPos.y, MonsterPos.z);
		D3DXMatrixScaling(&grow, 1/sizeModifier, 1/sizeModifier, 1/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Monster.Draw(Stone);
		//6		
		D3DXMatrixTranslation(&tripler, RavengerSirenPos.x, RavengerSirenPos.y, RavengerSirenPos.z);
		D3DXMatrixScaling(&grow, .1/sizeModifier, .1/sizeModifier, .1/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		RavengerSiren.Draw(Stone);
		//7		
		D3DXMatrixTranslation(&tripler, SectoidPos.x, SectoidPos.y, SectoidPos.z);
		D3DXMatrixScaling(&grow, 3/sizeModifier, 3/sizeModifier, 3/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Sectoid.Draw(Stone);
		//8		
		D3DXMatrixTranslation(&tripler, SlendermanPos.x, SlendermanPos.y, SlendermanPos.z);
		D3DXMatrixScaling(&grow, .05/sizeModifier, .05/sizeModifier, .05/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Slenderman.Draw(Stone);
		//9		
		D3DXMatrixTranslation(&tripler, SoccerPos.x, SoccerPos.y, SoccerPos.z);
		D3DXMatrixScaling(&grow, .05/sizeModifier, .05/sizeModifier, .05/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Soccer.Draw(Stone);
		//10		
		D3DXMatrixTranslation(&tripler, TurretPos.x, TurretPos.y, TurretPos.z);
		D3DXMatrixScaling(&grow, .1/sizeModifier, .1/sizeModifier, .1/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Turret.Draw(Stone);
		//11		
		D3DXMatrixTranslation(&tripler, UltramanPos.x, UltramanPos.y, UltramanPos.z);
		D3DXMatrixScaling(&grow, .01/sizeModifier, .01/sizeModifier, .01/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Ultraman.Draw(Stone);
		//12		
		D3DXMatrixTranslation(&tripler, ZombiePos.x, ZombiePos.y, ZombiePos.z);
		D3DXMatrixScaling(&grow, .1/sizeModifier, .1/sizeModifier, .1/sizeModifier);
		D3DXMatrixMultiply(&tripler, &grow, &tripler);
		Device->SetTransform(D3DTS_WORLD, &tripler);
		Zombie.Draw(Stone);

		if(!shrunk && p.z > 10)
		{
			shrunk = true;
			sound.AudioPlay(Voice);
			::MessageBoxA(0, "OH NO! you appear to be Shrinking\nStart Running to try and reach the manor", "Oh No!", MB_OK);
			DTime *= 5;
		}
		else if(shrunk)
		{
			
			if(sizeModifier >1)
			{
				sizeModifier-=.005;
			}
			else if(message)
			{
				message = false;
				::MessageBoxA(0, "It's too late, however you seem to be at the entrance to a castle and there appears to be some createures on the inside.\nMaybe you should try to approach one of them, Be Careful Though: they could be Evil", "Too Late", MB_OK);
			}
		}
		static bool approach = false;
		if(!approach)
			if(p.z > 125)
			{
				::MessageBoxA(0, "The creatures seem to be frozen and have had all their color drained...\nThey look like they were once the things that only exis in nightmares\nWhat kind of Powerfull Monster could have done this?\nMaybe you shouldn't have ignored those warnings.", "", MB_OK);
				approach = true;
			}
			static bool bang = false;
		if(p.z > 0)
		{
			if(!bang)
			{
				bang = true;
				sound.AudioPlay(Bang);
			}
			Device->SetStreamSource(0, VBufferGround, 0, sizeof(Vertex));
			Device->SetFVF(FVF_VERTEX);
			Device->SetTexture(0, DoNot);
			Device->SetTransform(D3DTS_WORLD, &i);
			Device->DrawPrimitive(D3DPT_TRIANGLELIST, 36, 2);
			Device->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
		}

		
		D3DXMATRIX V, T;
		TheCamera.getViewMatrix(&V);
		Device->SetTransform(D3DTS_VIEW, &V);
		TheCamera.getPosition(&p);
		if (p.y != 8.5)
			p.y = 8.5;
		TheCamera.setPosition(&p);
		TheCamera.getLook(&t);
		Device->EndScene();
		Device->Present(0, 0, 0, 0);
	}
	return true;
}