-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tank.cpp
68 lines (61 loc) · 1.45 KB
/
Tank.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
59
60
61
62
63
64
65
66
67
68
#include"Tank.h"
#include<TChar.h>
using namespace Gdiplus;
using namespace std;
void Tank::draw() {
if (_tank->isAlive() == false || _tank->available == false)
return;
//paint
int rba1 = 0, rba2 = 0;
if (_tank->getTeam() == 1)
rba1 = _tank->levelUPcooling/10;
else
rba2 = _tank->levelUPcooling/10;
HBRUSH bkbrush = CreateSolidBrush(RGB(10 + rba1, 10 + rba2, 30));
HPEN bkpen = CreatePen(PS_DASHDOT,4,RGB(200,200,200));
RECT rt = _tank->getPos();
SelectObject(*pDCObj, bkbrush);
if (_tank->levelUPcooling > 0) {
Ellipse(*pDCObj, rt.left - 10, rt.top - 10, rt.right + 10, rt.bottom + 10);
_tank->levelUPcooling-=10;
}
if (_tank->isPlayer) {
SelectObject(*pDCObj, bkpen);
Ellipse(*pDCObj, rt.left - 5, rt.top - 5, rt.right + 5, rt.bottom + 5);
}
//GdiplusImage
wstring tankges;
if(_tank->getTeam()==1)
tankges=L"tank\\enemy\\";
else
tankges=L"tank\\player\\";
switch (_tank->gesDirect())
{
case UP:
tankges+=L"up";
break;
case DOWN:
tankges+=L"down";
break;
case LEFT:
tankges+=L"left";
break;
case RIGHT:
tankges+=L"right";
break;
default:
break;
}
wstring level[5]={L"1",L"2",L"3",L"4",L"5"};
tankges+=level[_tank->getLevel()-1];
tankges+=L".png";
//
LPCWSTR pic=tankges.c_str();
Gdiplus::Image tank(pic);
Graphics g(*pDCObj);
Rect rect(_tank->Xpos(),_tank->Ypos(),_tank->tankSize,_tank->tankSize);
g.DrawImage(&tank, rect);
//release Mem
DeleteObject(bkbrush);
DeleteObject(bkpen);
}