📄 e.cpp
字号:
static POINT iMan; //人的位置
HDC hdc;
PAINTSTRUCT ps;
TEXTMETRIC tm;
TCHAR szBuffer [10];
switch ( message)
{
case WM_CREATE:
SetTimer ( hwnd, ID_TIMER, 300, NULL);
hdc = GetDC ( hwnd);
GetTextMetrics ( hdc, &tm);
cxChar = tm.tmAveCharWidth;
cxCaps = ( tm.tmPitchAndFamily & 1 ? 2 : 3)
* cxChar / 2;
cyChar = tm.tmHeight + tm.tmExternalLeading ;
iLevel = 0;
iNum = 0;
bMan = FALSE;
pLevelMap = NULL;
pDest = NULL;
pLevelMap = InitNewLevel ( iLevel);
pDest = InitDest ( pLevelMap);
iMan = InitMan ( pLevelMap);
pBox = InitBox ( pLevelMap);
ReleaseDC ( hwnd, hdc);
return 0;
case WM_SIZE:
cxClient = LOWORD ( lParam);
cyClient = HIWORD ( lParam);
return 0;
case WM_KEYDOWN:
switch ( wParam)
{
case VK_UP:
pPS0 = pLevelMap;
while ( pPS0) // while 1
{
if ( pPS0->Position .x == iMan.x &&
pPS0->Position .y == iMan.y - 1 &&
pPS0->i == 4)
// 为空
{
hdc = GetDC ( hwnd);
MoveCoordinate ( hdc, cxClient, cyClient);
SelectObject ( hdc, GetStockObject ( WHITE_PEN) );
DrawMan ( hdc, iMan);
iMan.y--;
iNum++;
SelectObject ( hdc, GetStockObject ( BLACK_PEN) );
DrawMan ( hdc, iMan);
// 如果原位置是目的 则要将该位置画白
pPs2 = pDest;
// 找到人原位置
while ( pPs2) // while 5
{
if( pPs2->Position.x == iMan.x &&
pPs2->Position.y == iMan.y + 1)
// iMan.y已减1
{
SelectObject ( hdc, GetStockObject ( WHITE_BRUSH) );
Drawdest ( hdc , iMan.x, iMan.y + 1);
break;
}// end if
pPs2 = pPs2->Next;
}//end while 5
break;
}// end if
else if ( pPS0->Position .x == iMan.x &&
pPS0->Position .y == iMan.y - 1 &&
pPS0->i == 2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -