Exemplo n.º 1
0
void CALLBACK
	OnGUIEvent(int ID)
{
	switch(ID)
	{
	case PLACE_TOWER:
		gui.GetButton(PLACE_TOWER)->SetPressed(true);
		return;
	}

}
Exemplo n.º 2
0
LRESULT CALLBACK
WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	POINT mousePos;
	int dx = 0;
	int dy = 0;

	switch( msg )
	{
	case WM_LBUTTONDOWN:
		if( wParam & MK_LBUTTON )
		{
			SetCapture(hwnd);

			mOldMousePos.x = ( short )LOWORD(lParam);
			mOldMousePos.y = ( short )HIWORD(lParam);
			gui.UpdateMouse(mOldMousePos.x,mOldMousePos.y,true);
		}
		return 0;

	case WM_LBUTTONUP:
		ReleaseCapture();
		return 0;

	case WM_RBUTTONDOWN:
		if( wParam & MK_RBUTTON )
		{
			SetCapture(hwnd);

			mOldMousePos.x = ( short )LOWORD(lParam);
			mOldMousePos.y = ( short )HIWORD(lParam);
			POINT d;
			d.x = ( short )LOWORD(lParam);
			d.y = ( short )HIWORD(lParam);
			//qtc.TEST(vp, d, qtc.getBLS(), 5, md3dDevice);
			if(gui.GetButton(PLACE_TOWER)->GetPressed())
			{
				D3DXVECTOR3 res = qtc.PlaceATower(vp, d);
				if (res != D3DXVECTOR3(-99,-99,-99))
				{
					mTowers.push_back(Tower());
					mTowers.back().init(md3dDevice, D3DXVECTOR3(7.5f, 7.5f, 7.5f), res);
					newCube = true;
					nrOfTowers.resize(mTowers.size());
					currentTower = (int)nrOfTowers.size()-1;
					gui.GetButton(PLACE_TOWER)->SetPressed(false);
				}
			}
			//cam.setLens(0.30f*(gameTime.getDeltaTime()*20), (float)SCREEN_WIDTH/SCREEN_HEIGHT, 1.0f, 1000.0f);
		}
		return 0;

	case WM_RBUTTONUP:
		GetCamera().setLens(0.30f*pi, (float)SCREEN_WIDTH/SCREEN_HEIGHT, 1.0f, 1000.0f);
		ReleaseCapture();
		return 0;

	case WM_MOUSEMOVE:
		if( wParam & MK_LBUTTON || wParam & MK_RBUTTON )
		{
			mousePos.x = ( short )LOWORD(lParam);
			mousePos.y = ( short )HIWORD(lParam);

			dx = mousePos.x - mOldMousePos.x;
			dy = mousePos.y - mOldMousePos.y;

			GetCamera().rotateY( dx * 0.0087266f );
			GetCamera().pitch( dy * 0.0087266f );

			mOldMousePos = mousePos;
		}
		return 0;

	case WM_KEYDOWN:
		if(wParam == VK_CONTROL) GetCamera().crouch();
		if(wParam == VK_SPACE)	
		{
			if (!jumping)
				GetCamera().setJump(GetTime().getGameTime());
			jumping = true;
		}
		if (GetAsyncKeyState('F') & 0x8000)
		{
			if (funRot)
				funRot = false;
			else
				funRot = true;
		}
		if (GetAsyncKeyState('R') & 0x8000)
		{
			if (grid)
				grid = false;
			else
				grid = true;
		}
		if (GetAsyncKeyState('O') & 0x8000)
		{
			if(!newCube)
			{
				Tower c;
				mTowers.push_back(c);
				mTowers.back().init(md3dDevice, D3DXVECTOR3(1.0f, 1.0f, 1.0f), GetCamera().getPos());
				newCube = true;
				nrOfTowers.resize(mTowers.size());
				currentTower = (int)nrOfTowers.size()-1;
			}
			else
				newCube = false;
		}
		if (GetAsyncKeyState('Z') & 0x8000) 
		{
			if(newCube)
				nrOfTowers[currentTower] = 0;
			else
				nrOfTowers[0] = 0;
		}
		if (GetAsyncKeyState('X') & 0x8000)
		{
			if(newCube)
				nrOfTowers[currentTower] = 3;
			else
				nrOfTowers[0] = 3;
		}
		if (GetAsyncKeyState('C') & 0x8000)
		{
			if(newCube)
				nrOfTowers[currentTower] = 6;
			else
				nrOfTowers[0] = 6;
		}
		if (GetAsyncKeyState('Q') & 0x8000)
		{
			pWave->CalldmgCalc(1,10000,"Fire");
			pWave->CalldmgCalc(0,10000,"Fire");
		}
		return 0;

		// WM_DESTROY is sent when the window is being destroyed.
	case WM_DESTROY:
		DestroyWindow(g_Hwnd);
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hwnd, msg, wParam, lParam);
}