-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraindrop.cpp
More file actions
69 lines (57 loc) · 1.16 KB
/
raindrop.cpp
File metadata and controls
69 lines (57 loc) · 1.16 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
#include "raindrop.h"
Raindrop::Raindrop(int x, int y, int size, int speed, int maxTrailLength)
: x(x), y(y), size(size), speed(speed) , maxTrailLength(maxTrailLength)
{
imageHeight = 720;
fadeDurationFactor = .75;
}
void Raindrop::update()
{
y += speed;
opacity = 1.0 - (static_cast<qreal>(getY()) / static_cast<qreal>(imageHeight)) * fadeDurationFactor;
previousPositions.push_back(QPoint(x, y));
if (previousPositions.size() > maxTrailLength)
{
previousPositions.erase(previousPositions.begin());
}
}
int Raindrop::getX() const
{
return x;
}
int Raindrop::getY() const
{
return y;
}
int Raindrop::getSize() const
{
return size;
}
int Raindrop::getMaxTrailLength() const
{
return maxTrailLength;
}
qreal Raindrop::getOpacity() const
{
return opacity;
}
void Raindrop::setX(int new_x)
{
y = new_x;
}
void Raindrop::setY(int new_y)
{
y = new_y;
}
void Raindrop::setSize(int new_size)
{
size = new_size;
}
void Raindrop::setMaxTrailLength(int new_maxTrailLength)
{
maxTrailLength = new_maxTrailLength;
}
void Raindrop::setImageHeight(int new_imageHeight)
{
imageHeight = new_imageHeight;
}