-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaddle.cpp
68 lines (56 loc) · 941 Bytes
/
paddle.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 "paddle.h"
#include <iostream>
Paddle::Paddle()
{
image.load("player.png");
rect = image.rect();
destroyed = false;
shield = 3;
resetState();
}
Paddle::~Paddle()
{
std::cout << ("Paddle deleted\n");
}
void Paddle::moveLeft(int left)
{
if(rect.left() >= 2)
rect.moveTo(left, rect.top());
}
void Paddle::moveRight(int right)
{
if(rect.right() <= 298)
rect.moveTo(right, rect.top());
}
void Paddle::resetState()
{
rect.moveTo(200, 360);
}
QRect Paddle::getRect()
{
return rect;
}
QImage & Paddle::getImage()
{
return image;
}
bool Paddle::isDestroyed()
{
return destroyed;
}
void Paddle::setDestroyed(bool destr)
{
destroyed = destr;
}
void Paddle::changeShield(int x)
{
shield += x;
}
int Paddle::getShield()
{
return shield;
}
void Paddle::setShield(int x)
{
shield = x;
}