1#include "Star.h"
2#include "Screen.h"
3#include "Math/Math.h"
4
5Star::Star(std::string name):Sprite(name)
6{
7 this->currAngle = 0;
8 this->angVelocity=0.003;
9 this->radius = 50;
10 this->AnimationType = Animation::Spin;
11 this->RotationCenter.Set(120,120);
12}
13
14Star::Star(std::string name, const Cubios::Math::Transform& t):Sprite(name,t)
15{
16 this->currAngle = 0;
17 this->angVelocity=0.003;
18 this->radius = 50;
19 this->AnimationType = Animation::Spin;
20 this->RotationCenter.Set(120,120);
21}
22
23Star::Star(std::string name, float x, float y):Sprite(name,x,y)
24{
25 this->currAngle = 0;
26 this->angVelocity=0.003;
27 this->radius = 50;
28 this->AnimationType = Animation::Spin;
29
30 this->RotationCenter.Set(120,120);
31}
32
33Star::~Star() { }
34
35Star* Star::Tick(uint32_t dt)
36{
37 switch(AnimationType)
38 {
39 case Animation::Spin:
40 this->pos.Set(RotationCenter.X+radius*sin(currAngle), RotationCenter.Y+radius*cos(currAngle));
41 break;
42 case Animation::UpAndDown:
43 this->pos.Set(RotationCenter.X, RotationCenter.Y+radius*cos(currAngle));
44 break;
45 case Animation::LeftAndRight:
46 this->pos.Set(RotationCenter.X+radius*sin(currAngle), RotationCenter.Y);
47 break;
48 }
49 currAngle+= angVelocity*float(dt);
50
51 if(currAngle>PI_2) currAngle-=PI_2;
52
53 return this;
54}
55
56Star* Star::RenderStep()
57{
58 this->SetPosition(this->pos);
59 return this;
60}