-
Notifications
You must be signed in to change notification settings - Fork 0
/
stickman.cpp
55 lines (40 loc) · 1.17 KB
/
stickman.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
#include "stickman.h"
Stickman::~Stickman() {
std::cout << "Deleted Stickman" << std::endl;
}
//Set the scaled dimensions of the stickman, depending on the given size
void Stickman::setDimensions() {
if (size == "tiny") {
width = getPixmap(1).width() * 0.6;
height = getPixmap(1).height() * 0.6;
}
else if (size == "normal") {
width = getPixmap(1).width();
height = getPixmap(1).height();
}
else if (size == "large") {
width = getPixmap(1).width() * 1.2;
height = getPixmap(1).height() * 1.2;
}
else if (size == "giant") {
width = getPixmap(1).width() * 1.5;
height = getPixmap(1).height() * 1.5;
}
}
Stickman::Stickman(std::string size,
int position,
double velocity)
: size(size),
position(position),
velocity(velocity) {
setDimensions();
}
void Stickman::updateStickman() {
setDimensions();
}
//Get the respective pixmap for the given frame
QPixmap Stickman::getPixmap(unsigned int frame) {
QString frame_path = ":img/stickman/frame" + QString::number(frame) + ".png";
QPixmap pix(frame_path);
return pix;
}