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
|
#include "explosion.h"
#include "graphics.h"
#include "gameobject.h"
#include "config.h"
#include <iostream>
using namespace std;
Explosion::Explosion(float pos_x, float pos_y, float size_x, float size_y) : GameObject(pos_x, pos_y, size_x, size_y, 0.0f, "explosion1_"){
time = graphics::getGlobalTime();
graphics::playSound(string(ASSET_PATH) + "explosion1_.mp3", 0.5f, false);
}
Explosion::~Explosion(){
}
void Explosion::update(){
if(graphics::getGlobalTime() - time > 550){
this -> setTerminate(true);
}
}
void Explosion::draw(){
for(int i=1;i<12;++i){
if(graphics::getGlobalTime() - time > i * 50){
graphics::Brush br;
br.outline_opacity = 0.0f;
br.texture = string(ASSET_PATH) + this -> getTexture() + to_string(i) + ".png";
graphics::drawRect(this -> getPosX(), this -> getPosY(), this -> getSizeX(), this -> getSizeY(), br);
}
}
}
bool Explosion::collidable(){
return false;
}
|