setRect (3,0);
InvalidateRect (temp);
InvalidateRect (korp);
temp.CopyRect (kol1);
kol1.OffsetRect (3,0);
InvalidateRect (temp);
InvalidateRect (kol1);
В
temp.CopyRect (kol2);
kol2.OffsetRect (3,0);
InvalidateRect (temp);
InvalidateRect (kol2);
temp.CopyRect (kr);
kr.OffsetRect (3,0);
InvalidateRect (temp);
InvalidateRect (kr);
temp.CopyRect (kr2);
if (kr2.top == 270)
{
kr2.top = 275;
}
else kr2.top = 270;
kr2.OffsetRect (3,0);
InvalidateRect (temp);
InvalidateRect (kr2);
}
else/* повернення в ліву стінку */
{
korp.SetRect (0,288,50,300);
kr.SetRect (30,280,40,288);
kr2.SetRect (10,270,25,288);
kol1.SetRect (5,295,15,305);
kol2.SetRect (35,295,45,305);
ns = 1;
move = 0;
InvalidateRect (ball1);
InvalidateRect (ball2);
InvalidateRect (ball3);
}
}
}
}
afx_msg void CMainWnd :: OnRed ()
{/ * реакція на вибір червоного кольору */
color = 0;
}
afx_msg void CMainWnd :: OnGreen ()
{/ * вибір зеленого кольору */
color = 1;
}
afx_msg void CMainWnd :: OnBlue ()
{
color = 2;
}
afx_msg void CMainWnd :: OnBegin ()
{
game = true;
color = 0;
move = 0;
svet.SetRect (200,100,240,230);
noga.SetRect (210,230,230,250);
ball1.SetRect (210,110,230,140);
ball2.SetRect (210,150,230,180);
ball3.SetRect (210,190,230,220);
korp.SetRect (0,288,50,300);
kr.SetRect (30,280,40,288);
kr2.SetRect (10,270,25,288);
kol1.SetRect (5,295,15,305);
kol2.SetRect (35,295,45,305);
SetTimer (1,100, NULL);
SetTimer (2,1000, NULL);
InvalidateRect (NULL);
}
BEGIN_MESSAGE_MAP (CMainWnd, CFrameWnd)
ON_COMMAND (IDM_EXIT, OnExit)
ON_COMMAND (IDM_BEGIN, OnBegin)
ON_COMMAND (IDM_RED, OnRed)
ON_COMMAND (IDM_GREEN, OnGreen)
ON_COMMAND (IDM_BLUE, OnBlue)
ON_WM_PAINT ()
ON_WM_TIMER ()
ON_WM_CHAR ()
END_MESSAGE_MAP ()
afx_msg void CMainWnd :: OnChar (UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (game)
{
switch (nChar)
{
case 234:
{
ns = 0;
break;
}
case 231:
{ns = 2;
move = 1;
break;
}
case 230:
{ns = 1;
}
}
InvalidateRect (ball1);
InvalidateRect (ball2);
InvalidateRect (ball3);
}
}
CApp app;
В
Лістинг файлу...