SHARE
TWEET

Untitled

a guest Jun 19th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "PAR_Explode.h"
  2.  
  3. namespace par
  4. {
  5.     Explode::Explode(const sf::Color col, const float sped, const int dur)
  6.     {
  7.         Color = col;
  8.  
  9.         Init();
  10.         Speed = sped;
  11.         Duration = dur;
  12.  
  13.         start_time = clock();
  14.  
  15.         line = sf::Shape::Line(sf::Vector2f(0,0), sf::Vector2f(5,0), 3, sf::Color(255,255,255));
  16.         randangle[0] = 0;
  17.         randangle[1] = 360;
  18.     }
  19.  
  20.     void Explode::Init()
  21.     {
  22.         Angle = sf::Randomizer::Random(randangle[0], randangle[1]);
  23.         start_time = clock();
  24.     }
  25.  
  26.  
  27.     void Explode::Step(sf::RenderWindow &rw)
  28.     {
  29.         line.SetColor(Color);
  30.         line.SetRotation(-Angle);
  31.         line.Move((cos(Angle * (3.14f/180)) * Speed) * rw.GetFrameTime(),( sin(Angle * (3.14f/180)) * Speed) * rw.GetFrameTime());
  32.         rw.Draw(line);
  33.         if(clock() - start_time >= Duration)
  34.         {
  35.             isOver = true;
  36.         }
  37.     }
  38.  
  39.     void Explode::SetPosition(const sf::Vector2f &pos)
  40.     {
  41.         line.SetPosition(pos);
  42.     }
  43. }
RAW Paste Data
Top