-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathball.h
67 lines (53 loc) · 996 Bytes
/
ball.h
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
#ifndef BALL_H
#define BALL_H
class Ball
{
public:
explicit Ball(int x, int y, int r) :
m_x(x), m_y(y), m_r(r), m_xSpeed(0), m_ySpeed(0), m_isLocked(false)
{
}
void addXAcceleration(double xAcceleration) { m_xSpeed += xAcceleration; }
void addYAcceleration(double yAcceleration) { m_ySpeed += yAcceleration; }
void move();
void lock();
void unlock();
bool isLocked() const { return m_isLocked; }
void setCenter(int newX, int newY)
{
m_x = newX;
m_y = newY;
}
int getX() const
{
return m_x;
}
void setX(int x)
{
m_x = x;
}
int getY() const
{
return m_y;
}
void setY(int y)
{
m_y = y;
}
int getRadius() const
{
return m_r;
}
int getMass() const
{
return m_r;
}
private:
int m_x;
int m_y;
int m_r;
double m_xSpeed;
double m_ySpeed;
bool m_isLocked;
};
#endif // BALL_H