-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbolt.cpp
More file actions
96 lines (73 loc) · 1.01 KB
/
Copy pathbolt.cpp
File metadata and controls
96 lines (73 loc) · 1.01 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "bolt.h"
#include <iostream>
Bolt::Bolt()
{
xdir = 1;
ydir = 1;
image.load("bolt.png");
rect = image.rect();
resetState();
}
Bolt::~Bolt() {
std::cout << ("Bolt deleted\n");
}
void Bolt::resetState()
{
rect.moveTo(150, 0);
}
void Bolt::autoMove()
{
rect.translate(67*xdir, 67*ydir);
if (rect.left() <= 0) {
xdir = 1;
}
if (rect.right() >= 700) {
xdir = -1;
}
if (rect.top() <= 0) {
ydir = 1;
}
if(rect.bottom()>=700){//move to top when bottom is reached
resetState();
}
}
void Bolt::moveBottom(int bottom)
{
rect.moveBottom(bottom);
}
void Bolt::moveTop(int top)
{
rect.moveTop(top);
}
void Bolt::moveLeft(int left)
{
rect.moveLeft(left);
}
void Bolt::moveRight(int right)
{
rect.moveRight(right);
}
void Bolt::setXDir(int x)
{
xdir = x;
}
void Bolt::setYDir(int y)
{
ydir = y;
}
int Bolt::getXDir()
{
return xdir;
}
int Bolt::getYDir()
{
return ydir;
}
QRect Bolt::getRect()
{
return rect;
}
QImage & Bolt::getImage()
{
return image;
}