1// This file is generated by WOWCube SDK project wizard
2
3#include <stdint.h>
4#include <string>
5#include <vector>
6#include <string>
7#include <memory>
8
9#include "AppManager.h"
10#include "SnotFlow.h"
11
12
13using namespace Cubios;
14using namespace Cubios::Math;
15using namespace Cubios::Gfx;
16
17//Applicaton initialization callback. Called once when CUB application starts
18void OnInit(Cubios::AppManager& appMgr)
19{
20 SnotFlow* theApp = new SnotFlow();
21
22 appMgr.SetApplication(theApp,"AAbbCCddEE");
23
24 theApp->InitializeResources();
25}
26
27
28SnotFlow::SnotFlow()
29{
30}
31
32SnotFlow::~SnotFlow()
33{
34 this->Scene.DisposeAllObjects();
35}
36
37void SnotFlow::InitializeResources()
38{
39 this->Scene.CreateObjectWithID(GfxObjects::myBackground,new Background(17,38,41));
40
41 this->Scene.CreateObjectWithID(GfxObjects::mySlime,new AnimatedSprite("slime","png",1,18,Transform(120,120,0)));
42 this->slime = dynamic_cast<AnimatedSprite*>(this->Scene[GfxObjects::mySlime]);
43 this->slime->SetPlaybackSpeed(50);
44 this->slime->SetPlaybackMode(AnimatedSprite::playbackMode_t::Loop);
45
46 this->Scene.CreateSoundWithID(0,new Sound("drop.mp3"));
47}
48
49//This callback is called every "tick" of cubeapp application loop
50void SnotFlow::on_Tick(uint32_t currentTime, uint32_t deltaTime)
51{
52 int16_t frame = this->slime->Tick(deltaTime);
53
54 if(frame == 10)
55 {
56 this->Scene.Play(0,100);
57 }
58}
59
60//This callback is called every time device is about to render visuals. Use it for calling your rendering code.
61void SnotFlow::on_Render(std::array<Cubios::Screen, 3>& screens)
62{
63 for(auto it = screens.begin(); it != screens.end(); ++it)
64 {
65 //Start adding objects to a screen
66 it->Begin(TOPOLOGY_orientation_mode_t::ORIENTATION_MODE_GRAVITY,true);
67
68 //Add animated sprite on the sides of a cube
69 if(it->Direction()!=TOPOLOGY_orientation_t::ORIENTATION_UP && it->Direction()!=TOPOLOGY_orientation_t::ORIENTATION_DOWN)
70 {
71 it->Add(this->slime);
72 }
73 else
74 {
75 //Add background
76 it->Add(this->Scene[GfxObjects::myBackground]);
77 }
78
79 //Finish adding objects
80 it->End();
81 }
82}
83
84//The "physics" callback. Gets called recurrently with at least 33ms resolution or less depending on the load.
85void SnotFlow::on_PhysicsTick(const std::array<Cubios::Screen, 3>& screens)
86{
87}
88
89//This callback is called on programmable timer (if any)
90void SnotFlow::on_Timer(uint8_t timerID)
91{
92}
93
94//The cube topology change callback. Gets called when cube is twisted and its topological desctiption has been changed
95void SnotFlow::on_Twist(const Cubios::TOPOLOGY_twistInfo_t& twist)
96{
97}
98
99//The "inner network" callback. Gets called when WOWCube module receives a data packet from other module
100void SnotFlow::on_Message(uint32_t type, uint8_t* pkt, u32_t size)
101{
102}
103
104//The external data transfer callback. Gets called when WOWCube module receives a data over BLE from an external source
105void SnotFlow::on_ExternalMessage(uint8_t* pkt, u32_t size)
106{
107}
108
109//Screen tap callback
110void SnotFlow::on_Tap(uint32_t count)
111{
112}