1// This PAWN script is generated by WOWCube SDK project wizard
2
3#define G2D
4
5#pragma warning disable 203
6#pragma warning disable 213
7#pragma warning disable 229
8
9// Includes
10// -----------------------------
11
12#include "wowcore.inc"
13#include "topology.inc"
14#include "graphics.inc"
15#include "motion_sensor.inc"
16#include "math.inc"
17#include "log.inc"
18
19// Application defines
20// -----------------------------
21#define TEXT_SIZE 10
22
23// Application constants
24// ------------------------------
25new const Colors[.white, .black, .red, .green, .blue] =
26[
27 0xFFFFFFFF,
28 0xFF000000,
29 0xFFFF0000,
30 0xFF003f00,
31 0xFF0000FF,
32];
33
34// Application variables
35// -----------------------------
36new Images[.first,.second,.third,.fourth];
37new iconPos[GFX_POINT];
38
39// WOWCube application callbacks
40// -----------------------------
41
42//Applicaton initialization callback. Called once when CUB application starts
43public ON_Init(id, size, const pkt[])
44{
45 LOG_i("\n");
46 LOG_i("*** WOWCube SDK Example \"Topology - Orientation\" ***\n\n");
47
48 LOG_i("Cubeapp is initializing...\n");
49 LOG_i("Cubeapp is started on module %d\n",SELF_ID);
50
51 Images.first = GFX_getAssetId("0.png");
52 Images.second = GFX_getAssetId("1.png");
53 Images.third = GFX_getAssetId("2.png");
54 Images.fourth = GFX_getAssetId("3.png");
55
56 iconPos.x = 120;
57 iconPos.y = 120;
58
59 LOG_i("Done.\n");
60}
61
62//Saved application state data load callback. Gets called in response to loadState() function call
63public ON_Load(id, size, const pkt[])
64{
65}
66
67//Main run loop callback. Gets called recurrently by the CUB application as frequent as application code allows.
68public ON_Tick()
69{
70}
71
72//This callback is gets called immediately after ON_Tick(). Use it for calling your rendering code.
73public ON_Render()
74{
75 new place[TOPOLOGY_PLACE];
76 new facelet[TOPOLOGY_FACELET_INFO];
77 new face = TOPOLOGY_getFace(ORIENTATION_UP);
78
79 for(new screenNumber = 0; screenNumber<3; screenNumber++)
80 {
81 GFX_setRenderTarget(screenNumber);
82 GFX_clear(Colors.black);
83
84 for (new screenPositionIndex = 0; screenPositionIndex < TOPOLOGY_POSITIONS_MAX; screenPositionIndex++)
85 {
86 place.face = face;
87 place.position = screenPositionIndex;
88
89 facelet = TOPOLOGY_getFacelet(place);
90
91 if(SELF_ID == facelet.module && screenNumber == facelet.screen)
92 {
93 switch(screenPositionIndex)
94 {
95 case 0: GFX_drawImage([120,120], 0xFF, 0, 100, 100, 180, MIRROR_BLANK, Images.first);
96 case 1: GFX_drawImage([120,120], 0xFF, 0, 100, 100, 90, MIRROR_BLANK, Images.second);
97 case 2: GFX_drawImage([120,120], 0xFF, 0, 100, 100, 0, MIRROR_BLANK, Images.third);
98 case 3: GFX_drawImage([120,120], 0xFF, 0, 100, 100, 270, MIRROR_BLANK, Images.fourth);
99
100 }
101 }
102 }
103
104 GFX_render();
105 }
106}
107
108
109//The "physics" callback. Gets called recurrently with 30ms resolution.
110public ON_PhysicsTick()
111{
112}
113
114//The "inner network" callback. Gets called when WOWCube module receives a data packet from other module
115public ON_Packet(type, size, const pkt[])
116{
117}
118
119//The cube topology change callback. Gets called when cube is twisted and its topological desctiption has been changed
120
121public ON_Twist(twist[TOPOLOGY_TWIST_INFO])
122{
123}
124
125//Device shake detection callback.
126public ON_Shake(const count)
127{
128}
129
130//Screen tap callback.
131public ON_Tap(const count, const display, const bool:opposite)
132{
133 if (SELF_ID == 0)
134 {
135 }
136 else
137 {
138 }
139}
140
141//Application quit callback.
142public ON_Quit()
143{
144 //
145 //Save game data here
146 //
147}
148
149// User-defined functions
150// -----------------------------