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
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 0xFF00FF00,
31 0xFF0000FF,
32];
33
34// Global variables
35// ----------------------------
36new previousTime = 0;
37new currentTime = 0;
38new deltaTime = 0;
39
40new seconds = 0;
41
42new Fixed:fps = 0;
43new timer[.delay, .time];
44
45// WOWCube application callbacks
46// -----------------------------
47
48//Applicaton initialization callback. Called once when CUB application starts
49public ON_Init(id, size, const pkt[])
50{
51 previousTime = getTime();
52
53 timer.delay = 1000;
54 timer.time = previousTime;
55}
56
57//Saved application state data load callback. Gets called in response to loadState() function call
58public ON_Load(id, size, const pkt[])
59{
60}
61
62//Main run loop callback. Gets called recurrently by the CUB application as frequent as application code allows.
63public ON_Tick()
64{
65 currentTime = getTime();
66 deltaTime = currentTime - previousTime;
67 previousTime = currentTime;
68
69 if(deltaTime>0)
70 {
71 fps = fdiv(fixed(1000),fixed(deltaTime));
72 }
73 else
74 fps = 0;
75
76 if(currentTime - timer.time >= timer.delay)
77 {
78 timer.time = currentTime;
79 seconds++;
80
81 if(seconds>99) seconds = 0;
82 }
83}
84
85//This callback is gets called immediately after ON_Tick(). Use it for calling your rendering code.
86public ON_Render()
87{
88 for(new screenNumber = 0; screenNumber<3; screenNumber++)
89 {
90 GFX_setRenderTarget(screenNumber);
91 GFX_clear(Colors.black);
92
93 GFX_drawText([ 120,80 ], TEXT_SIZE, 0, 0, TEXT_ALIGN_CENTER, Colors.white, "dt: %d ms", deltaTime);
94 GFX_drawText([ 120,120 ], TEXT_SIZE, 0, 0, TEXT_ALIGN_CENTER, Colors.green, "fps: %q", fps);
95 GFX_drawText([ 120,160 ], TEXT_SIZE, 0, 0, TEXT_ALIGN_CENTER, Colors.blue, "timer: %d s", seconds);
96
97 GFX_render();
98 }
99}
100
101//The "physics" callback. Gets called recurrently with 30ms resolution.
102public ON_PhysicsTick()
103{
104}
105
106//The "inner network" callback. Gets called when WOWCube module receives a data packet from other module
107public ON_Packet(type, size, const pkt[])
108{
109}
110
111//The cube topology change callback. Gets called when cube is twisted and its topological desctiption has been changed
112public ON_Twist(twist[TOPOLOGY_TWIST_INFO])
113{
114 if (SELF_ID == 0)
115 {
116 }
117 else
118 {
119 }
120}
121
122//Device shake detection callback.
123public ON_Shake(const count)
124{
125}
126
127//Screen tap callback.
128public ON_Tap(const count, const display, const bool:opposite)
129{
130 if (SELF_ID == 0)
131 {
132 }
133 else
134 {
135 }
136}
137
138//Application quit callback.
139public ON_Quit()
140{
141 //
142 //Save game data here
143 //
144}