@auraindustry/aurajs 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/benchmarks/perf-thresholds.json +102 -0
- package/package.json +47 -0
- package/src/.gitkeep +0 -0
- package/src/asset-pack.mjs +316 -0
- package/src/build-contract.mjs +71 -0
- package/src/bundler.mjs +698 -0
- package/src/cli.mjs +764 -0
- package/src/config.mjs +460 -0
- package/src/conformance-runner.mjs +322 -0
- package/src/conformance.mjs +5407 -0
- package/src/headless-test.mjs +4314 -0
- package/src/host-binary.mjs +423 -0
- package/src/perf-benchmark-runner.mjs +233 -0
- package/src/perf-benchmark.mjs +549 -0
- package/src/postinstall.mjs +26 -0
- package/src/scaffold.mjs +74 -0
- package/templates/starter/aura.config.json +28 -0
- package/templates/starter/src/main.js +226 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// {{PROJECT_NAME}} — built with AuraJS
|
|
2
|
+
// Optional modules are opt-in in aura.config.json:
|
|
3
|
+
// - modules.physics: enables aura.physics.*
|
|
4
|
+
// - modules.network: enables aura.net.*
|
|
5
|
+
// - modules.steam: enables aura.steam.*
|
|
6
|
+
|
|
7
|
+
let x = 400;
|
|
8
|
+
let y = 300;
|
|
9
|
+
let speed = 200;
|
|
10
|
+
let highlightUntilRelease = false;
|
|
11
|
+
let movedOutsideBounds = false;
|
|
12
|
+
const PLAYER_SPRITE_PATH = "player.png";
|
|
13
|
+
const HUD_FONT_PATH = "fonts/ui.ttf";
|
|
14
|
+
|
|
15
|
+
function keyDown(name) {
|
|
16
|
+
if (aura.input && typeof aura.input.isKeyDown === "function") {
|
|
17
|
+
return aura.input.isKeyDown(name);
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function keyPressed(name) {
|
|
23
|
+
if (aura.input && typeof aura.input.isKeyPressed === "function") {
|
|
24
|
+
return aura.input.isKeyPressed(name);
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function keyReleased(name) {
|
|
30
|
+
if (aura.input && typeof aura.input.isKeyReleased === "function") {
|
|
31
|
+
return aura.input.isKeyReleased(name);
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getWindowSize() {
|
|
37
|
+
if (aura.window && typeof aura.window.getSize === "function") {
|
|
38
|
+
return aura.window.getSize();
|
|
39
|
+
}
|
|
40
|
+
return { width: 800, height: 600 };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getFPS() {
|
|
44
|
+
if (aura.window && typeof aura.window.getFPS === "function") {
|
|
45
|
+
return aura.window.getFPS();
|
|
46
|
+
}
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function rgb(r, g, b) {
|
|
51
|
+
if (typeof aura.rgb === "function") {
|
|
52
|
+
return aura.rgb(r, g, b);
|
|
53
|
+
}
|
|
54
|
+
return { r, g, b, a: 1 };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function rgba(r, g, b, a) {
|
|
58
|
+
if (typeof aura.rgba === "function") {
|
|
59
|
+
return aura.rgba(r, g, b, a);
|
|
60
|
+
}
|
|
61
|
+
return { r, g, b, a };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function colorWhite() {
|
|
65
|
+
if (aura.Color && aura.Color.WHITE) {
|
|
66
|
+
return aura.Color.WHITE;
|
|
67
|
+
}
|
|
68
|
+
return rgb(1, 1, 1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function colorYellow() {
|
|
72
|
+
if (aura.Color && aura.Color.YELLOW) {
|
|
73
|
+
return aura.Color.YELLOW;
|
|
74
|
+
}
|
|
75
|
+
return rgb(1, 1, 0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function rectRect(a, b) {
|
|
79
|
+
if (aura.collision && typeof aura.collision.rectRect === "function") {
|
|
80
|
+
return aura.collision.rectRect(a, b);
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function hasAsset(path) {
|
|
86
|
+
if (aura.assets && typeof aura.assets.exists === "function") {
|
|
87
|
+
return aura.assets.exists(path);
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function measureTextSafe(text, options) {
|
|
93
|
+
if (aura.draw2d && typeof aura.draw2d.measureText === "function") {
|
|
94
|
+
return aura.draw2d.measureText(text, options);
|
|
95
|
+
}
|
|
96
|
+
return { width: 0, height: 0 };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function clearScreen(color) {
|
|
100
|
+
try {
|
|
101
|
+
aura.draw2d.clear(color);
|
|
102
|
+
} catch {
|
|
103
|
+
aura.draw2d.clear(color.r, color.g, color.b, color.a);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
aura.setup = function () {
|
|
108
|
+
console.log("{{PROJECT_NAME}} started");
|
|
109
|
+
if (!hasAsset(PLAYER_SPRITE_PATH)) {
|
|
110
|
+
console.log(`Tip: add assets/${PLAYER_SPRITE_PATH} to preview sprite draw2d options.`);
|
|
111
|
+
}
|
|
112
|
+
if (!hasAsset(HUD_FONT_PATH)) {
|
|
113
|
+
console.log(`Tip: add assets/${HUD_FONT_PATH} to preview text font selection.`);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
aura.update = function (dt) {
|
|
118
|
+
if (keyDown("arrowright")) x += speed * dt;
|
|
119
|
+
if (keyDown("arrowleft")) x -= speed * dt;
|
|
120
|
+
if (keyDown("arrowup")) y -= speed * dt;
|
|
121
|
+
if (keyDown("arrowdown")) y += speed * dt;
|
|
122
|
+
|
|
123
|
+
if (keyPressed("space")) {
|
|
124
|
+
highlightUntilRelease = true;
|
|
125
|
+
}
|
|
126
|
+
if (keyReleased("space")) {
|
|
127
|
+
highlightUntilRelease = false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const { width, height } = getWindowSize();
|
|
131
|
+
movedOutsideBounds = !rectRect(
|
|
132
|
+
{ x: x - 16, y: y - 16, w: 32, h: 32 },
|
|
133
|
+
{ x: 0, y: 0, w: width, h: height }
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
x = aura.math.clamp(x, 0, width);
|
|
137
|
+
y = aura.math.clamp(y, 0, height);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
aura.draw = function () {
|
|
141
|
+
const bg = rgba(0.08, 0.08, 0.12, 1.0);
|
|
142
|
+
clearScreen(bg);
|
|
143
|
+
|
|
144
|
+
const spriteOptions = {
|
|
145
|
+
width: 32,
|
|
146
|
+
height: 32,
|
|
147
|
+
scaleX: 1,
|
|
148
|
+
scaleY: 1,
|
|
149
|
+
rotation: highlightUntilRelease ? 0.25 : 0,
|
|
150
|
+
originX: 0.5,
|
|
151
|
+
originY: 0.5,
|
|
152
|
+
tint: highlightUntilRelease ? colorYellow() : colorWhite(),
|
|
153
|
+
alpha: movedOutsideBounds ? 0.75 : 1
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
if (hasAsset(PLAYER_SPRITE_PATH)) {
|
|
157
|
+
aura.draw2d.sprite(PLAYER_SPRITE_PATH, x, y, spriteOptions);
|
|
158
|
+
} else {
|
|
159
|
+
aura.draw2d.pushTransform();
|
|
160
|
+
aura.draw2d.translate(x, y);
|
|
161
|
+
aura.draw2d.rotate(spriteOptions.rotation);
|
|
162
|
+
aura.draw2d.rect(
|
|
163
|
+
-16,
|
|
164
|
+
-16,
|
|
165
|
+
32,
|
|
166
|
+
32,
|
|
167
|
+
highlightUntilRelease ? colorYellow() : rgb(0.39, 0.78, 1.0)
|
|
168
|
+
);
|
|
169
|
+
aura.draw2d.popTransform();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const fps = getFPS().toFixed(0);
|
|
173
|
+
const padSummary = [
|
|
174
|
+
aura.input.isGamepadConnected(0) ? "P1" : "-",
|
|
175
|
+
aura.input.isGamepadConnected(1) ? "P2" : "-",
|
|
176
|
+
aura.input.isGamepadConnected(2) ? "P3" : "-",
|
|
177
|
+
aura.input.isGamepadConnected(3) ? "P4" : "-"
|
|
178
|
+
].join(" ");
|
|
179
|
+
const moveHint = movedOutsideBounds ? " (clamped)" : "";
|
|
180
|
+
const hudTextOptions = {
|
|
181
|
+
color: colorWhite(),
|
|
182
|
+
size: 16,
|
|
183
|
+
align: "left"
|
|
184
|
+
};
|
|
185
|
+
if (hasAsset(HUD_FONT_PATH)) {
|
|
186
|
+
hudTextOptions.font = HUD_FONT_PATH;
|
|
187
|
+
}
|
|
188
|
+
aura.draw2d.text(
|
|
189
|
+
`Arrow keys: move | Space: hold highlight | FPS ${fps}${moveHint} | Pads ${padSummary}`,
|
|
190
|
+
10,
|
|
191
|
+
10,
|
|
192
|
+
hudTextOptions
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
const measureOptions = { size: 12 };
|
|
196
|
+
if (hasAsset(HUD_FONT_PATH)) {
|
|
197
|
+
measureOptions.font = HUD_FONT_PATH;
|
|
198
|
+
}
|
|
199
|
+
const metrics = measureTextSafe("AS8 parity", measureOptions);
|
|
200
|
+
aura.draw2d.text(
|
|
201
|
+
`measureText("AS8 parity") => ${metrics.width.toFixed(1)} x ${metrics.height.toFixed(1)}`,
|
|
202
|
+
10,
|
|
203
|
+
30,
|
|
204
|
+
{ color: colorWhite(), size: 12, align: "left" }
|
|
205
|
+
);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/*
|
|
209
|
+
Verification snippets (copy into setup()/update()/draw() as needed):
|
|
210
|
+
|
|
211
|
+
1) Draw-only no-op semantics:
|
|
212
|
+
aura.update = function () {
|
|
213
|
+
aura.draw2d.rect(0, 0, 10, 10, aura.Color.RED); // ignored outside draw()
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
2) Transform stack limits:
|
|
217
|
+
aura.draw = function () {
|
|
218
|
+
for (let i = 0; i < 80; i += 1) aura.draw2d.pushTransform();
|
|
219
|
+
for (let i = 0; i < 80; i += 1) aura.draw2d.popTransform();
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
3) Font fallback parity:
|
|
223
|
+
const a = aura.draw2d.measureText("Hello", { size: 18 });
|
|
224
|
+
const b = aura.draw2d.measureText("Hello", { size: 18, font: "missing.ttf" });
|
|
225
|
+
console.log("font fallback identical:", a.width === b.width && a.height === b.height);
|
|
226
|
+
*/
|