-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexplosion.cpp
More file actions
36 lines (30 loc) · 785 Bytes
/
explosion.cpp
File metadata and controls
36 lines (30 loc) · 785 Bytes
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
#include "explosion.h"
#include "map.h"
#include "tank.h"
Explosion::Explosion(Map & map, Tank & tank){
if(!tank.player)
map.destroyedEnemey += 1;
img = map.spr.wybuch;
img.scale(map.pr.scale, map.pr.scale);
img.setPosition(tank.pos);
img.setTextureRect(sf::IntRect(0, 0, 100, 100));
timer.restart();
sound.Sounds["explosion"].play();
}
void Explosion::update(){
if (timer.getElapsedTime().asSeconds() >= 0.4){
if (imgNum < 2) imgNum++;
img.setTextureRect(sf::IntRect(imgNum * 100, 0, 100, 100));
timer.restart();
}
}
bool Explosion::stillExist(){
if (sound.Sounds["explosion"].getStatus() == sf::Sound::Status::Playing){
update();
return 1;
}
else return 0;
}
void Explosion::draw(sf::RenderTarget & wndow, sf::RenderStates) const{
wndow.draw(img);
}