该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
static int cxChar, cyChar;
static HWND hwndButton[10];
switch (message)
{
case WM_CREATE:
case WM_PAINT:
if (Flag)
{
PrepareSnake();
SetSnakeTime(hWnd, DEFAULT);
cxChar = 2 * LOWORD(GetDialogBaseUnits());
cyChar = 2 * LOWORD(GetDialogBaseUnits());
hwndButton[0] = CreateWindow(
TEXT("button"),
TEXT("Start"),
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
330,
180,
cxChar * 10,
cxChar * 2,
hWnd,
(HMENU)0,
((LPCREATESTRUCT)lParam)->hInstance,
ID_START);
return 0;
}
hdc = BeginPaint(hWnd, &ps);
DrawSnake(hWnd, hdc);
if (!CheckLife(SnakeHead->x, SnakeHead->y))
{
KillTimer(hWnd, ID_RunTime);
LOGFONT font;
ZeroMemory(&font, sizeof(LOGFONT));
font.lfHeight = SizeOfGameOver;
HFONT hFont = CreateFontIndirect(&font);
SetTextColor(hdc, GOColor);
SelectObject(hdc, hFont);
TextOut(hdc, GAME_x, GAME_y, TEXT("GAME"), strlen("GAME"));
TextOut(hdc, OVER_x, OVER_y, TEXT("OVER"), strlen("OVER"));
Death = TRUE;
return 0;
}
return 0;
EndPaint(hWnd, &ps);