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. main.pwn
Mission NodeSDK 6.3PawntopologyProject Included

main.pwn

Example: main.pwn

Examples / SDK 6.3 / Pawn / topology / Handling Twists / project / src
main.pwn
C
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 Application[.screen,.direction,.animationOffset];
37new Icons[.left,.right,.dbl];
38new iconPos[GFX_POINT];
39
40// WOWCube application callbacks
41// -----------------------------
42
43//Applicaton initialization callback. Called once when CUB application starts
44public ON_Init(id, size, const pkt[])
45{
46 LOG_i("\n");
47 LOG_i("*** WOWCube SDK Example \"Topology - Handling Twists\" ***\n\n");
48
49 LOG_i("Cubeapp is initializing...\n");
50 LOG_i("Cubeapp is started on module %d\n",SELF_ID);
51
52 Application.screen = -1;
53 Application.direction = -1;
54 Application.animationOffset = 0;
55
56 Icons.left = GFX_getAssetId("left.png");
57 Icons.right = GFX_getAssetId("right.png");
58 Icons.dbl = GFX_getAssetId("dbl.png");
59
60 iconPos.x = 120;
61 iconPos.y = 120;
62
63 LOG_i("Done.\n");
64}
65
66//Saved application state data load callback. Gets called in response to loadState() function call
67public ON_Load(id, size, const pkt[])
68{
69}
70
71//Main run loop callback. Gets called recurrently by the CUB application as frequent as application code allows.
72public ON_Tick()
73{
74}
75
76//This callback is gets called immediately after ON_Tick(). Use it for calling your rendering code.
77public ON_Render()
78{
79 for(new screenNumber = 0; screenNumber<3; screenNumber++)
80 {
81 GFX_setRenderTarget(screenNumber);
82 GFX_clear(Colors.black);
83
84 if(screenNumber == Application.screen)
85 {
86 iconPos.x = 120+Application.animationOffset;
87 switch(Application.direction)
88 {
89 case TWIST_LEFT: { iconPos.x = 120+Application.animationOffset; GFX_drawImage(iconPos, 0xFF, 0, 100, 100, 0, MIRROR_BLANK, Icons.left); }
90 case TWIST_RIGHT: { iconPos.x = 120-Application.animationOffset; GFX_drawImage(iconPos, 0xFF, 0, 100, 100, 0, MIRROR_BLANK, Icons.right); }
91 case TWIST_DOUBLE: GFX_drawImage([120,120], 0xFF, 0, 100, 100, 0, MIRROR_BLANK, Icons.dbl);
92 }
93 }
94
95 GFX_render();
96 }
97}
98
99
100//The "physics" callback. Gets called recurrently with 30ms resolution.
101public ON_PhysicsTick()
102{
103 if(Application.animationOffset>0)
104 Application.animationOffset-=50;
105}
106
107//The "inner network" callback. Gets called when WOWCube module receives a data packet from other module
108public ON_Packet(type, size, const pkt[])
109{
110}
111
112//The cube topology change callback. Gets called when cube is twisted and its topological desctiption has been changed
113
114public ON_Twist(twist[TOPOLOGY_TWIST_INFO])
115{
116 Application.screen = twist.screen;
117 Application.direction = twist.direction;
118
119 Application.animationOffset = 200;
120}
121
122//Screen pat callback.
123public ON_Pat(const count, const display, const bool:opposite)
124{
125 if (SELF_ID == 0)
126 {
127 }
128 else
129 {
130 }
131}
132
133//Application quit callback.
134public ON_Quit()
135{
136 //
137 //Save game data here
138 //
139}
140
141// User-defined functions
142// -----------------------------
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Project files

main.pwn
project/src/main.pwn
wowcubeapp-build.json
project/wowcubeapp-build.json
Context Rail

Related nodes

Handling Twists
Examples / SDK 6.3 / Pawn / topology
info.json
Examples / SDK 6.3 / Pawn / topology / Handling Twists
wowcubeapp-build.json
Examples / SDK 6.3 / Pawn / topology / Handling Twists / project
Device Orientation
Examples / SDK 6.3 / Pawn / topology
Previous Node
info.json
Examples / SDK 6.3 / Pawn / topology / Handling Twists
Next Node
wowcubeapp-build.json
Examples / SDK 6.3 / Pawn / topology / Handling Twists / project