-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathMill.cpp
58 lines (47 loc) · 1.1 KB
/
Mill.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Mill.cpp: implementation of the CMill class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "resource.h"
#include "Mill.h"
#include "Panel.h"
#include <MMSYSTEM.H>
#pragma comment(lib, "winmm.lib")
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern HINSTANCE hInst;
CMill::CMill()
{
}
CMill::~CMill()
{
}
void CMill::DoApple()
{
m_pos.x=rand()%GRIDXNUMBER;
m_pos.y=rand()%GRIDXNUMBER;
}
void CMill::Draw(HDC hDC,CPanel *pPanel)
{
TransparentBlt(hDC,pPanel->GetGcx()*m_pos.x,pPanel->GetGcx()*m_pos.y,pPanel->GetGcx(),pPanel->GetGcy(),
AppleDC,0,0,47,47,RGB(255,0,0));
}
bool CMill::EatApple()
{
if(!PlaySound((LPCTSTR)IDR_EAT, NULL, SND_RESOURCE | SND_ASYNC)) OnErr();
if(m_AppleNum>0)
{
m_AppleNum--;
DoApple();
Sleep(50);
return true;
}
return false;
}
void CMill::InitDraw(HDC hDC)
{
appleBmp=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_APPLE));
AppleDC=CreateCompatibleDC(hDC);
SelectObject(AppleDC,appleBmp);
}