#define WIN32_LEAN_AND_MEAN #include #include "resource.h" #include "tdx.h" int TDX_screenx=640; int TDX_screeny=480; int key=0; TDXmessage message; BOOL Init() { TDXinit(); TDXsetdebugmode(true); TDXsetdebugcolor(RGB(255,255,255)); TDXshowcursorposition(true); TDXloadmouse("images/pointer.bmp",25,25); DEBUG("Game Start "); message.SetPos(50,300); message.SetFont("Comic Sans MS",10,20); message.SetText("Press CTRL+ALT+G to enter God mode"); return TRUE; } void EndGame( void ) { TDXendgame(); } void GamePlay() { key=0; TDXupdateinput(); TDXclearscreen(0); if (isPress(CDXKEY_ESCAPE)) { SendMessage(h_window, WM_CLOSE, 0, 0); return; } if (isHit(CDXKEY_A)) DEBUG("You press A"); if (isHit(CDXKEY_Z)) DEBUG("You press Z"); if (isPress(CDXKEY_LEFTCTRL)) key+=5; if (isPress(CDXKEY_LEFTALT)) key+=2; if (isPress(CDXKEY_G)) key+=1; if (key==8) DEBUG("GOD MODE"); message.ShowText(); TDXshowmouse(); TDXgameflip(); } static long PASCAL WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_TIMER: { if (wParam==SECSUPERFAST) { } if (wParam==SECVERYFAST) { } if (wParam==SECFAST) { } if (wParam==SEC03) { } if (wParam==SEC05) { } if (wParam==SEC07) { } if (wParam==SEC1) { } if (wParam==SEC2) { } if (wParam==SEC3) { } if (wParam==SEC5) { } if (wParam==SEC8) { } if (wParam==SEC10) { } if (wParam==SEC15) { } if (wParam==SEC20) { } if (wParam==SEC30) { } }break; case WM_CHAR: { // [Text Box].UpdateKey(LOWORD(wParam)); }break; case WM_MOUSEMOVE: { int x=LOWORD(lParam); int y=HIWORD(lParam); TDXupdatemouse(x,y); }break; case WM_SETCURSOR: SetCursor(NULL); return 1; case WM_CLOSE: EndGame(); case WM_DESTROY: PostQuitMessage(0); return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); } } int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) { MSG msg; h_instance = hInstance; WNDCLASS WndClass; WndClass.style = CS_HREDRAW | CS_VREDRAW; WndClass.lpfnWndProc = WinProc; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hInstance = h_instance; WndClass.hIcon = LoadIcon(h_instance, "APPICON"); WndClass.hCursor = LoadCursor(0, IDC_ARROW); WndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); WndClass.lpszMenuName = 0; WndClass.lpszClassName = szClassName; RegisterClass(&WndClass); h_window = CreateWindowEx( 0, szClassName, "MyGame", WS_OVERLAPPED | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU, 0, 0, 320, 240, NULL, NULL, h_instance, NULL); if( !h_window ) CDXError( NULL , "could not create the main window" ); AdjustWinStyle(TDX_screenx, TDX_screeny); ShowWindow(h_window, nCmdShow); UpdateWindow(h_window); if(!Init()) { PostQuitMessage(0); return FALSE; } while(1) { if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { if(!GetMessage(&msg, NULL, 0, 0 )) return msg.wParam; TranslateMessage(&msg); DispatchMessage(&msg); } else { GamePlay(); } } }