-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExplosion.cpp
45 lines (44 loc) · 921 Bytes
/
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
#include "../Explosion.h"
#include<iostream>
#include <SFML/Graphics.hpp>
void Explosion::Create(float ObjX,float ObjY,sf::RenderWindow& window,std::string GameObj,int no)
{
float xPos = ObjX;
float yPos=ObjY;
static std::string ObjName=GameObj;
static int objNum = no;
sf::Texture explosionText;
if (!explosionText.loadFromFile("resources/explosion.png"))
{
std::cout << "Cannot load explosion" << std::endl;
}
int width=64;
int height = 64;
static int counter = 0;
static int x = 0;
static int y = 0;
sf::Sprite explosionSprite(explosionText,sf::IntRect(x, y, width, height));
explosionSprite.setPosition(sf::Vector2f(xPos, yPos-50.0f));
window.draw(explosionSprite);
x += width;
if (x > (64*4))
{
x = 0;
y += 64;
counter++;
}
if (counter > 2)
{
if (ObjName == GameObj && objNum==no)
{
}
else
{
ObjName = GameObj;
objNum = no;
counter = 0;
x = 0;
y = 0;
}
}
}