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#include "wowcore.inc"
12#include "topology.inc"
13#include "graphics.inc"
14#include "fixed.inc"
15#include "motion_sensor.inc"
16#include "math.inc"
17#include "log.inc"
18#include "string.inc"
19
20// Application defines
21// -----------------------------
22#define TEXT_SIZE 6
23
24// Application constants
25// ------------------------------
26new const Colors[.white, .black, .red, .green, .blue] =
27[
28 0xFFFFFFFF,
29 0xFF000000,
30 0xFFFF0000,
31 0xFF00FF00,
32 0xFF0000FF,
33];
34
35// Global variables
36// ----------------------------
37new previousTime = 0;
38new currentTime = 0;
39new deltaTime = 0;
40
41new seconds = 0;
42
43 new stringBuffer[4]; //in pawn, buffer size is measured in 'cells'. The size of one 'cell' is 4 bytes. This buffer will be 16 bytes long therefore.
44
45new Fixed:fps = 0;
46new timer[.delay, .time];
47
48// WOWCube application callbacks
49// -----------------------------
50
51//Applicaton initialization callback. Called once when CUB application starts
52public ON_Init(id, size, const pkt[])
53{
54 LOG_i("\n");
55 LOG_i("*** WOWCube SDK Example \"Working with Emulator\" ***\n\n");
56
57 LOG_i("Cubeapp is initializing...\n");
58 LOG_i("Cubeapp is started on module %d\n",SELF_ID);
59
60 previousTime = getTime();
61
62 timer.delay = 1000;
63 timer.time = previousTime;
64
65 LOG_i("Done.\n");
66}
67
68//Saved application state data load callback. Gets called in response to loadState() function call
69public ON_Load(id, size, const pkt[])
70{
71}
72
73//Main run loop callback. Gets called recurrently by the CUB application as frequent as application code allows.
74public ON_Tick()
75{
76 currentTime = getTime();
77 deltaTime = currentTime - previousTime;
78 previousTime = currentTime;
79
80 if(deltaTime>0)
81 fps = fdiv(fixed(1000),fixed(deltaTime));
82 else
83 fps = 0;
84
85 if(currentTime - timer.time >= timer.delay)
86 {
87 timer.time = currentTime;
88 seconds++;
89
90 LOG_i(" Seconds passed: %d (integer value)\n",seconds);
91
92 LOG_i(" Current FPS: %q (fixed point value)\n",fps);
93
94 strformat(stringBuffer, sizeof(stringBuffer), true, "%d ms", deltaTime);
95 LOG_i(" Delta time: %s (string)\n",stringBuffer);
96
97 LOG_i(" Delta time in HEX: 0x%x (hexadecimal value)\n\n",deltaTime);
98
99 if(seconds>99) seconds = 0;
100 }
101}
102
103//This callback is gets called immediately after ON_Tick(). Use it for calling your rendering code.
104public ON_Render()
105{
106 for(new screenNumber = 0; screenNumber<3; screenNumber++)
107 {
108 GFX_setRenderTarget(screenNumber);
109 GFX_clear(Colors.black);
110
111 GFX_drawText([ 120,80 ], TEXT_SIZE, 0, 0, TEXT_ALIGN_CENTER, Colors.green, "CHECK");
112 GFX_drawText([ 120,120 ], TEXT_SIZE, 0, 0, TEXT_ALIGN_CENTER, Colors.green, "THE");
113 GFX_drawText([ 120,160 ], TEXT_SIZE, 0, 0, TEXT_ALIGN_CENTER, Colors.green, "CONSOLE");
114
115 GFX_render();
116 }
117}
118
119//The "physics" callback. Gets called recurrently with 30ms resolution.
120public ON_PhysicsTick()
121{
122}
123
124//The "inner network" callback. Gets called when WOWCube module receives a data packet from other module
125public ON_Packet(type, size, const pkt[])
126{
127}
128
129//The cube topology change callback. Gets called when cube is twisted and its topological desctiption has been changed
130public ON_Twist(twist[TOPOLOGY_TWIST_INFO])
131{
132 if (SELF_ID == 0)
133 {
134 }
135 else
136 {
137 }
138}
139
140//Device shake detection callback.
141public ON_Shake(const count)
142{
143}
144
145//Screen tap callback.
146public ON_Tap(const count, const display, const bool:opposite)
147{
148 if (SELF_ID == 0)
149 {
150 }
151 else
152 {
153 }
154}
155
156//Application quit callback.
157public ON_Quit()
158{
159 //
160 //Save game data here
161 //
162}
163