1// This header file is generated by WOWCube SDK project wizard
2#pragma once
3#include "Gfx.h"
4
5#define DISPLAY_CENTER_X 120
6#define DISPLAY_CENTER_Y 120
7
8#define SCREEN_WIDTH 240
9#define SCREEN_HEIGHT 240
10
11#define NUM_MAGNETS 4
12#define PARTICLES_PER_MAGNET 15
13#define MAGNETIC_FORCE_THRESHOLD 300
14
15enum MyColors
16{
17 marsh=0xFF161D24
18};
19
20typedef struct
21{
22 float x;
23 float y;
24 float size;
25 float orbit;
26} Magnet_t;
27
28typedef struct
29{
30 float x;
31 float y;
32 float shx;
33 float shy;
34 float angle;
35 float size;
36 float speed;
37 float force;
38 int magnet;
39 float orbit;
40} Particle_t;
41
42class Circles: public Cubios::Application
43{
44public:
45 Circles();
46 virtual ~Circles();
47
48 virtual void on_PhysicsTick(const std::array<Cubios::Screen, 3>& screens) override;
49 virtual void on_Twist(const Cubios::TOPOLOGY_twistInfo_t& twist) override;
50 virtual void on_Message(uint32_t type, uint8_t* pkt, u32_t size) override;
51 virtual void on_ExternalMessage(uint8_t* pkt, u32_t size) override;
52 virtual void on_Tap(uint32_t count) override;
53 virtual void on_Render(std::array<Cubios::Screen, 3>& screens) override;
54 virtual void on_Tick(uint32_t currentTime, uint32_t deltaTime) override;
55 virtual void on_Timer(uint8_t timerID) override;
56
57 void InitializeResources();
58
59private:
60 void createMagnet(float x,float y);
61 void moveMagnets();
62 void createParticles(float x, float y, int magnet);
63 void renderParticles();
64
65 float distanceSquared(float x1, float y1, float x2, float y2);
66private:
67 //array of attractors ("magnets")
68 Magnet_t magnets[NUM_MAGNETS];
69 int numMagnets;
70 int magnetsShift;
71
72 //array of particles
73 Particle_t particles[NUM_MAGNETS*PARTICLES_PER_MAGNET];
74 int numParticles;
75};