-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpillar.cpp
52 lines (41 loc) · 1.26 KB
/
pillar.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
#include "pillar.h"
Pillar::Pillar(QWidget *parent,uint32_t xPos, uint32_t yPos): Entity(parent, xPos, yPos)
{
QPixmap pillarPixMap;
if (pillarPixMap.load("../../Assets/pillar.png"))
{
qDebug() << "Pillar image is loaded!";
}
else
{
qDebug() << "Failed to load the pillar image.";
}
// Resizing bird image:
pillarPixMap = pillarPixMap.scaled((parent->width() * 0.1), (parent->height() * 0.3), Qt::KeepAspectRatio, Qt::SmoothTransformation);
this->setPixmap(pillarPixMap);
this->setGeometry(this->getPosX(), this->getPosY(), pillarPixMap.width(), pillarPixMap.height());
this->raise();
this->show();
// Debugging output:
qDebug() << "QLabel pillar geometry:" << this->geometry();
qDebug() << "QLabel is pillar visible:" << this->isVisible();
}
uint32_t Pillar::calculatePillarGap()
{
return QRandomGenerator::global()->bounded(150, 350);
}
void Pillar::placePillar(size_t t)
{
}
void Pillar::generatePillar(QWidget *parent , uint32_t xPos, uint32_t yPos )
{
const uint32_t pillarNumber = 4;
const uint32_t pillarGap = 100; // in px
for (size_t i = 0; i < pillarNumber; i++)
{
if (i % 2 == 0)
placePillar(i);
else
placePillar(i);
}
}