-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwall.cpp
62 lines (58 loc) · 1.85 KB
/
wall.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
// Name: Jarrod King, Tyler Harkness, Axe Tang, Sam Farrell, Coltin Thiede
// Class: CS3505
// Assignment: A8
#include "wall.h"
///
/// \brief Wall::Wall - the constructor for the wall class
/// \param pos - this is the position of the wall side
/// \param seed - a random seed used for generating the walls, since C++'s random generator is sudo-random.
///
Wall::Wall(doorPosition pos, int seed)
{
position = pos;
if (pos == LeftDoor) {
image = QImage(":/walls/Wall_Vertical.png");
image = image.scaledToHeight(canvasHeight);
image = image.scaledToWidth(wallWidth);
rect = image.rect();
rect.moveTo(0,0);
}
else if (pos == RightDoor) {
image = QImage(":/walls/Wall_Vertical.png");
image = image.scaledToHeight(canvasHeight);
image = image.scaledToWidth(wallWidth);
rect = image.rect();
rect.moveTo(canvasWidth-wallWidth, 0);
}
else if (pos == TopDoor) {
image = QImage(":/walls/Wall_Horizontal.png");
image = image.scaledToHeight(wallWidth);
image = image.scaledToWidth(canvasWidth - 2 * wallWidth);
rect = image.rect();
rect.moveTo(wallWidth, 11);
}
else if (pos == BottomDoor) {
image = QImage(":/walls/Wall_Horizontal.png");
image = image.scaledToHeight(wallWidth);
image = image.scaledToWidth(canvasWidth - 2 * wallWidth);
rect = image.rect();
rect.moveTo(wallWidth, canvasHeight - wallWidth);
}
srand(time(nullptr)-seed);
for (int i=0;i<21;i++) {
srand(rand());
}
}
QImage Wall::getImage() {
return image;
}
QRect Wall::getRect() {
return rect;
}
///
/// \brief Wall::getPos - returns the side of the wall in the room
/// \return - the wall side
///
doorPosition Wall::getPos() {
return position;
}