create-bloop 0.0.6 → 0.0.8
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/dist/index.js +2 -1
- package/package.json +1 -1
- package/templates/hello/gitignore +2 -0
- package/templates/hello/package.json +3 -3
- package/templates/hello/src/main.ts +6 -8
- package/templates/mario/gitignore +2 -0
- package/templates/mario/package.json +3 -3
- package/templates/mario/src/draw.ts +11 -5
- package/templates/mario/src/main.ts +13 -22
- package/templates/mario/src/tape-load.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -5016,7 +5016,8 @@ function copyDir(src, dest) {
|
|
|
5016
5016
|
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
5017
5017
|
for (const entry of entries) {
|
|
5018
5018
|
const srcPath = path.join(src, entry.name);
|
|
5019
|
-
const
|
|
5019
|
+
const destName = entry.name === "gitignore" ? ".gitignore" : entry.name;
|
|
5020
|
+
const destPath = path.join(dest, destName);
|
|
5020
5021
|
if (entry.isDirectory()) {
|
|
5021
5022
|
copyDir(srcPath, destPath);
|
|
5022
5023
|
} else {
|
package/package.json
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
2
|
import { Toodle } from "@bloopjs/toodle";
|
|
3
3
|
import { start } from "@bloopjs/web";
|
|
4
|
-
import { draw } from "./draw";
|
|
4
|
+
import { draw as drawFn } from "./draw";
|
|
5
5
|
import { game } from "./game";
|
|
6
6
|
|
|
7
|
-
// temp - use a monorepo dev wasm url instead of cdn
|
|
8
|
-
const monorepoWasmUrl = new URL("/bloop-wasm/bloop.wasm", window.location.href);
|
|
9
|
-
|
|
10
7
|
// 1. Set up simulation
|
|
11
8
|
const app = await start({
|
|
12
9
|
game,
|
|
13
|
-
engineWasmUrl: monorepoWasmUrl,
|
|
14
10
|
});
|
|
15
11
|
|
|
16
12
|
// 2. Set up rendering
|
|
13
|
+
let draw = drawFn;
|
|
17
14
|
const canvas = document.querySelector("canvas");
|
|
18
15
|
if (!canvas) throw new Error("Canvas element not found");
|
|
19
16
|
const toodle = await Toodle.attach(canvas);
|
|
@@ -24,7 +21,8 @@ requestAnimationFrame(function frame() {
|
|
|
24
21
|
|
|
25
22
|
// 3. Set up Hot Module Replacement (HMR)
|
|
26
23
|
import.meta.hot?.accept("./game", async (newModule) => {
|
|
27
|
-
await app.acceptHmr(newModule?.game
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
await app.acceptHmr(newModule?.game);
|
|
25
|
+
});
|
|
26
|
+
import.meta.hot?.accept("./draw", async (newModule) => {
|
|
27
|
+
draw = newModule?.draw;
|
|
30
28
|
});
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { unwrap } from "@bloopjs/bloop";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
Color,
|
|
4
|
+
QuadNode,
|
|
5
|
+
SceneNode,
|
|
6
|
+
TextNode,
|
|
7
|
+
Toodle,
|
|
8
|
+
} from "@bloopjs/toodle";
|
|
3
9
|
import { Colors } from "@bloopjs/toodle";
|
|
4
10
|
import {
|
|
5
11
|
BLOCK_SIZE,
|
|
@@ -33,11 +39,11 @@ export interface DrawState {
|
|
|
33
39
|
p1: PoseQuads;
|
|
34
40
|
p2: PoseQuads;
|
|
35
41
|
viewport: SceneNode;
|
|
36
|
-
p1Score:
|
|
37
|
-
p2Score:
|
|
42
|
+
p1Score: TextNode;
|
|
43
|
+
p2Score: TextNode;
|
|
38
44
|
// Title elements (under titleScreen)
|
|
39
|
-
titleText:
|
|
40
|
-
subtitleText:
|
|
45
|
+
titleText: TextNode;
|
|
46
|
+
subtitleText: TextNode;
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
export function createDrawState(toodle: Toodle): DrawState {
|
|
@@ -5,16 +5,10 @@ import { createChromaticAberrationEffect } from "./chromatic-aberration";
|
|
|
5
5
|
import { createDrawState, draw as drawFn } from "./draw";
|
|
6
6
|
import { game } from "./game";
|
|
7
7
|
|
|
8
|
-
// In dev, vite serves wasm from /bloop-wasm/. In prod, it's bundled at ./bloop.wasm
|
|
9
|
-
const wasmUrl = import.meta.env.DEV
|
|
10
|
-
? new URL("/bloop-wasm/bloop.wasm", window.location.href)
|
|
11
|
-
: new URL("./bloop.wasm", import.meta.url);
|
|
12
|
-
|
|
13
8
|
let draw = drawFn;
|
|
14
9
|
|
|
15
10
|
const app = await start({
|
|
16
11
|
game,
|
|
17
|
-
engineWasmUrl: wasmUrl,
|
|
18
12
|
startRecording: false,
|
|
19
13
|
debugUi: {
|
|
20
14
|
initiallyVisible: false,
|
|
@@ -26,7 +20,6 @@ if (!canvas) throw new Error("No canvas element found");
|
|
|
26
20
|
|
|
27
21
|
const toodle = await Toodle.attach(canvas, {
|
|
28
22
|
filter: "nearest",
|
|
29
|
-
backend: "webgpu",
|
|
30
23
|
limits: { textureArrayLayers: 5 },
|
|
31
24
|
});
|
|
32
25
|
|
|
@@ -71,15 +64,17 @@ window.addEventListener("keydown", (e) => {
|
|
|
71
64
|
}
|
|
72
65
|
});
|
|
73
66
|
|
|
74
|
-
// Debug: Press G to toggle glitch effect
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
67
|
+
// Debug: Press G to toggle glitch effect on webgpu backend
|
|
68
|
+
if (toodle.backend.type === "webgpu") {
|
|
69
|
+
const glitchEffect = createChromaticAberrationEffect(toodle);
|
|
70
|
+
let glitchEnabled = false;
|
|
71
|
+
window.addEventListener("keydown", (e) => {
|
|
72
|
+
if (e.key === "g") {
|
|
73
|
+
glitchEnabled = !glitchEnabled;
|
|
74
|
+
toodle.postprocess = glitchEnabled ? glitchEffect : null;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
83
78
|
|
|
84
79
|
game.system("title-input", {
|
|
85
80
|
update({ bag, inputs }) {
|
|
@@ -113,14 +108,10 @@ game.system("title-input", {
|
|
|
113
108
|
// HMR support
|
|
114
109
|
if (import.meta.hot) {
|
|
115
110
|
import.meta.hot.accept("./game", async (newModule) => {
|
|
116
|
-
|
|
117
|
-
await app.acceptHmr(newModule.game, { wasmUrl });
|
|
118
|
-
}
|
|
111
|
+
await app.acceptHmr(newModule?.game);
|
|
119
112
|
});
|
|
120
113
|
|
|
121
114
|
import.meta.hot.accept("./draw", async (newModule) => {
|
|
122
|
-
|
|
123
|
-
draw = newModule.draw;
|
|
124
|
-
}
|
|
115
|
+
draw = newModule?.draw;
|
|
125
116
|
});
|
|
126
117
|
}
|
|
@@ -33,7 +33,7 @@ async function loadTape(bytes: Uint8Array, fileName: string) {
|
|
|
33
33
|
// Start the app with recording disabled (we're loading a tape)
|
|
34
34
|
const app = await start({
|
|
35
35
|
game,
|
|
36
|
-
|
|
36
|
+
wasmUrl: wasmUrl,
|
|
37
37
|
debugUi: true,
|
|
38
38
|
startRecording: false,
|
|
39
39
|
});
|