WOWCube Docs logo
WOWCube Docs
Mission Control
Section Shortcuts
APIExamplesSourceWOWConnectChangelog
Filters
SDK and language defaults persist in cookies.
SDK version
Navigation Tree
Collapsed by default, focused on the active path.
Made byMcKay Seamons
GitHub
  1. Home
  2. Docs
  3. Examples
  4. Star.cpp
Mission NodeSDK 6.2C++GFX SamplesProject Included

Star.cpp

Example: Star.cpp

Examples / SDK 6.2 / C++ / GFX Samples / Twinkle Stars / project / src
Star.cpp
CPP
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}
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Project files

Star.cpp
project/src/Star.cpp
Star.h
project/src/Star.h
Twinkle.cpp
project/src/Twinkle.cpp
Twinkle.h
project/src/Twinkle.h
wowcubeapp-build.json
project/wowcubeapp-build.json
Context Rail

Related nodes

Star.h
Examples / SDK 6.2 / C++ / GFX Samples / Twinkle Stars / project / src
Twinkle.cpp
Examples / SDK 6.2 / C++ / GFX Samples / Twinkle Stars / project / src
Twinkle.h
Examples / SDK 6.2 / C++ / GFX Samples / Twinkle Stars / project / src
Twinkle Stars
Examples / SDK 6.2 / C++ / GFX Samples
Previous Node
info.json
Examples / SDK 6.2 / C++ / GFX Samples / Twinkle Stars
Next Node
Star.h
Examples / SDK 6.2 / C++ / GFX Samples / Twinkle Stars / project / src