-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexplosion.cpp
59 lines (44 loc) · 1.03 KB
/
explosion.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
#include "explosion.h"
QVector<QPixmap*> Explosion::frames;
Explosion::Explosion(QPoint point)
{
gameObjectType = GameObject::Type::Asteroid;
rect = QRect(point.x(),point.y(),100,100);
frame = frames.first();
lives = 1;
}
bool Explosion::makeFramesFromPixmap(){
if(frames.isEmpty()){
static const QPixmap pixmap(":/images/images/explosionAsteroid.png");
for(int i=0; i<32;i++){
frames.push_back(new QPixmap(pixmap.copy(i*62,0,62,62)));
}
}
return true;
}
void Explosion::animate(Animated::Animation type){
if(frame != frames.last()){
frame = frames[frames.indexOf(frame)+1];
}else{
frame = frames.first();
}
hurt();
}
void Explosion::reuse(QPoint point){
rect = QRect(point.x(),point.y(),100,100);
frame = frames.first();
lives = 32;
}
void Explosion::draw(std::shared_ptr<QPainter> painter)
{
painter->drawPixmap(rect,*frame);
}
void Explosion::read(const QJsonObject &json)
{
}
void Explosion::write(QJsonObject &json) const
{
}
void Explosion::move()
{
}