-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
191e03a
commit 721d6ff
Showing
17 changed files
with
174 additions
and
14 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "particles.h" | ||
#include "myrandom.h" | ||
#include <iostream> | ||
|
||
|
||
particles::particles(sf::RenderWindow & App, sf::Texture & tx_particle, unsigned int amount, sf::Color color) | ||
: entity(tx_particle, {0,0}), App(App), amount(amount){ | ||
|
||
for(int i=0; i<amount; ++i) { | ||
sf::Sprite temp; | ||
temp.setTexture(tx_particle); | ||
temp.setPosition(-100, -100); | ||
temp.setColor(color); | ||
temp.rotate(randomInt(0, 360)); | ||
particle temp2; | ||
temp2.sp_part = temp; | ||
particles_.push_back(temp2); | ||
} | ||
speed = 100; | ||
lifeTime = sf::seconds(1); | ||
alpha = 255; | ||
|
||
} | ||
|
||
particles::~particles() { | ||
particles_.clear(); | ||
} | ||
|
||
void particles::spawn(int x, int y) { | ||
for(auto& e:particles_) { | ||
e.sp_part.setPosition(x, y); | ||
e.velX = 0.125 * randomInt(-8,8); | ||
e.velY = 0.125 * randomInt(-8,8); | ||
} | ||
} | ||
|
||
void particles::move(sf::Time dT) { | ||
lifeTime -= dT; | ||
if(lifeTime.asMilliseconds() < 0) { | ||
particles_.clear(); | ||
} | ||
alpha -= 10; | ||
if (alpha <= 0) { alpha = 10; } | ||
for (auto& e : particles_) { | ||
float x = e.sp_part.getPosition().x; | ||
float y = e.sp_part.getPosition().y; | ||
|
||
e.sp_part.setPosition(x + e.velX * dT.asSeconds() * speed, y + e.velY * dT.asSeconds() * speed); | ||
int r = e.sp_part.getColor().r; | ||
int g = e.sp_part.getColor().g; | ||
int b = e.sp_part.getColor().b; | ||
e.sp_part.setColor(sf::Color(r, g, b, alpha + randomInt(0, 10))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
#include "entity.h" | ||
|
||
struct particle { | ||
sf::Sprite sp_part; | ||
float velX = 0; | ||
float velY = 0; | ||
}; | ||
|
||
class particles : public entity{ | ||
sf::RenderWindow& App; | ||
std::vector<particle> particles_; | ||
unsigned int amount; | ||
int speed; | ||
sf::Time lifeTime; | ||
int alpha; | ||
public: | ||
particles(sf::RenderWindow &App, sf::Texture& tx_particle, unsigned int amount, sf::Color color); | ||
~particles(); | ||
void spawn(int x, int y); | ||
void move(sf::Time dT); | ||
std::vector<particle> getVector() { return particles_; } | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//{{NO_DEPENDENCIES}} | ||
// Microsoft Visual C++ generated include file. | ||
// Used by PUTBRCK.rc | ||
// | ||
#define IDI_ICON1 102 | ||
|
||
// Next default values for new objects | ||
// | ||
#ifdef APSTUDIO_INVOKED | ||
#ifndef APSTUDIO_READONLY_SYMBOLS | ||
#define _APS_NEXT_RESOURCE_VALUE 103 | ||
#define _APS_NEXT_COMMAND_VALUE 40001 | ||
#define _APS_NEXT_CONTROL_VALUE 1001 | ||
#define _APS_NEXT_SYMED_VALUE 101 | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters