-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathctreasure.cpp
39 lines (35 loc) · 920 Bytes
/
ctreasure.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
#include "ctreasure.h"
#include <QRandomGenerator>
#include "cmap.h"
CTreasure::CTreasure(CMap *m)
:CNonMovable(QRandomGenerator::global()->bounded(-map_size/2, map_size/2),
QRandomGenerator::global()->bounded(-map_size/2, map_size/2),
0,
0,
QRandomGenerator::global()->bounded(20, 50),
m)
{
objectShape = Square;
width = value;
height = value;
}
CTreasure::~CTreasure()
{
}
//treasures are worth less with time
void CTreasure::update()
{
int decrease = (QRandomGenerator::global()->bounded(50));
if(!decrease)
{
value-=(QRandomGenerator::global()->bounded(1, 2));
if(value<10)value=10;
}
width = value;
height = value;
}
//when treasure is collected, remove it from the map
void CTreasure::getCollected()
{
map->deleteFromMap(this);
}