Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "PAR_Explode.h"
- namespace par
- {
- Explode::Explode(const sf::Color col, const float sped, const int dur)
- {
- Color = col;
- Init();
- Speed = sped;
- Duration = dur;
- start_time = clock();
- line = sf::Shape::Line(sf::Vector2f(0,0), sf::Vector2f(5,0), 3, sf::Color(255,255,255));
- randangle[0] = 0;
- randangle[1] = 360;
- }
- void Explode::Init()
- {
- Angle = sf::Randomizer::Random(randangle[0], randangle[1]);
- start_time = clock();
- }
- void Explode::Step(sf::RenderWindow &rw)
- {
- line.SetColor(Color);
- line.SetRotation(-Angle);
- line.Move((cos(Angle * (3.14f/180)) * Speed) * rw.GetFrameTime(),( sin(Angle * (3.14f/180)) * Speed) * rw.GetFrameTime());
- rw.Draw(line);
- if(clock() - start_time >= Duration)
- {
- isOver = true;
- }
- }
- void Explode::SetPosition(const sf::Vector2f &pos)
- {
- line.SetPosition(pos);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement