-
Notifications
You must be signed in to change notification settings - Fork 0
/
mon.cpp
55 lines (38 loc) · 1.03 KB
/
mon.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
#include "mon.h"
#include <iostream>
Mon::Mon()
{
xdir = 0;
ydir = 1; // Make downwards as the direction of the object in the y axis
image.load("M.png"); //Make the picture of a 'S' icon as the object image
rect = image.rect();
}
Mon::~Mon() {
std::cout << ("Ball deleted\n");
}
void Mon::autoMove(int level,int x)
{
rect.translate(xdir, level);
if (rect.top() == 0) {
ydir = 1;
}
}
void Mon::resetState(int x) { // function for setting the initial position of the icon
srand(time(0));
rect.moveTo(rand()%230, 0);
}
void Mon::moveBottom(int bottom){ //function for moving the icon to the bottom
rect.moveBottom(bottom);
}
void Mon::setYDir(int y){ // function for setting the direction the icon is moving towards on the y axis
ydir = y;
}
int Mon::getYDir(){ // function for getting the direction the icon is moving towards on the y axis
return ydir;
}
QRect Mon::getRect(){ //function for getting the Rect
return rect;
}
QImage & Mon::getImage(){ // function for returning the image
return image;
}