This repository was archived by the owner on Jan 8, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.cpp
More file actions
64 lines (62 loc) · 1.17 KB
/
Point.cpp
File metadata and controls
64 lines (62 loc) · 1.17 KB
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
#include "Point.h"
#include <cstdlib>
#include <windows.h>
#include <WinUser.h>
const unsigned short MSB = 0x8000;
bool listenKeyPress(short p_key);
void Point::Locate(int* xl, int* yl)
{
*xl = x;
*yl = y;
}
/// <summary>
/// Óñòàíàâëèâàåò ðàíäîìíûé öâåò èç 15 äîñòóïíûõ, êðîìå ÷¸ðíîãî
/// </summary>
void Point::ChangeColor()
{
color = rand() % 15 + 1;
}
int Point::GetMaxX()
{
return framework->get_x();
}
int Point::GetMaxY()
{
return framework->get_y();
}
void Point::Fly(int cost)
{
int xx, yy;
Locate(&xx, &yy);
int state = 0;
Show();
do
{
/*do
{
xx = xx + round((rand() % 10 - 5) * cost / 10);
} while (!(xx > 0 && xx < GetMaxX()));
do
{
yy = yy + round((rand() % 10 - 5) * cost / 10);
} while (!(yy > 0 && yy < GetMaxY()));*/
int n_xx = xx + round((rand() % 10 - 5) * cost / 10);
int n_yy = yy + round((rand() % 10 - 5) * cost / 10);
if (n_xx > 0 && n_xx < GetMaxX() && n_yy > 0 && n_yy < GetMaxY())
{
xx = n_xx;
yy = n_yy;
Hide();
x = xx;
y = yy;
ChangeColor();
ChangeEndAngle();
Show();
Sleep(300);
}
} while (!listenKeyPress(VK_RETURN));
}
bool listenKeyPress(short p_key)
{
return (GetAsyncKeyState(p_key) & MSB);
}