-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
58 lines (42 loc) · 1.06 KB
/
main.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
#include <iostream>
#include <winbgim.h>
struct BgiWindowProperties {
int xLength{};
int yLength{};
std::string title{};
};
struct Pos {
int x{};
int y{};
};
class Ball {
public:
Pos m_topLeft{};
// Size of the side of the square which encloses the ball
// Should be even
int m_size{};
int getRadius() {
return m_size / 2;
}
Pos getBottomRight() {
return {m_topLeft.x + (m_size - 1), m_topLeft.y + (m_size - 1)};
}
Pos getCentre() {
int radius {getRadius()};
return {m_topLeft.x + radius, m_topLeft.y + radius};
}
void draw() {
Pos centre = getCentre();
int radius {getRadius()};
fillellipse(centre.x, centre.y, radius, radius);
}
};
int main() {
const BgiWindowProperties windowProperties {800, 600, "Unnamed Ball Game" };
initwindow(windowProperties.xLength, windowProperties.yLength, windowProperties.title.c_str());
Ball ball {.m_topLeft {0, 0}, .m_size = 22};
ball.draw();
getch();
closegraph();
return 0;
}