create-exo-app 0.1.0 → 0.19.0

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.
Files changed (57) hide show
  1. package/README.md +30 -29
  2. package/bin/create-exo-app.js +3 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +2 -118
  5. package/dist/scaffold.d.ts +44 -0
  6. package/dist/scaffold.js +190 -0
  7. package/package.json +25 -8
  8. package/templates/audio-reactive/index.html +13 -3
  9. package/templates/audio-reactive/package.json +7 -3
  10. package/templates/audio-reactive/src/main.ts +4 -3
  11. package/templates/audio-reactive/src/scenes/AudioReactiveScene.ts +3 -3
  12. package/templates/game-starter/index.html +13 -3
  13. package/templates/game-starter/package.json +6 -3
  14. package/templates/game-starter/src/main.ts +5 -3
  15. package/templates/game-starter/src/objects/Player.ts +1 -1
  16. package/templates/game-starter/src/scenes/GameOverScene.ts +11 -17
  17. package/templates/game-starter/src/scenes/GameScene.ts +59 -26
  18. package/templates/minimal/index.html +13 -3
  19. package/templates/minimal/package.json +6 -3
  20. package/templates/minimal/src/main.ts +5 -4
  21. package/templates/minimal/src/scenes/MainScene.ts +3 -8
  22. package/templates/platformer/README.md +13 -0
  23. package/templates/platformer/index.html +25 -0
  24. package/templates/platformer/package.json +21 -0
  25. package/templates/platformer/public/assets/ART-LICENSE.txt +28 -0
  26. package/templates/platformer/public/assets/platformer-characters.json +1093 -0
  27. package/templates/platformer/public/assets/platformer-characters.png +0 -0
  28. package/templates/platformer/public/assets/platformer-tiles.json +7549 -0
  29. package/templates/platformer/public/assets/platformer-tiles.png +0 -0
  30. package/templates/platformer/src/main.ts +19 -0
  31. package/templates/platformer/src/objects/Player.ts +139 -0
  32. package/templates/platformer/src/scenes/PlatformerScene.ts +237 -0
  33. package/templates/platformer/tsconfig.json +12 -0
  34. package/templates/platformer/vite.config.ts +5 -0
  35. package/templates/top-down/README.md +27 -0
  36. package/templates/top-down/index.html +25 -0
  37. package/templates/top-down/package.json +24 -0
  38. package/templates/top-down/public/assets/ART-LICENSE.txt +21 -0
  39. package/templates/top-down/public/assets/characters.json +1093 -0
  40. package/templates/top-down/public/assets/characters.png +0 -0
  41. package/templates/top-down/public/assets/map-pack.png +0 -0
  42. package/templates/top-down/public/assets/town-square.tmj +689 -0
  43. package/templates/top-down/src/level.ts +59 -0
  44. package/templates/top-down/src/main.ts +29 -0
  45. package/templates/top-down/src/scenes/ProceduralMapScene.ts +74 -0
  46. package/templates/top-down/src/scenes/TiledMapScene.ts +33 -0
  47. package/templates/top-down/src/scenes/TopDownScene.ts +208 -0
  48. package/templates/top-down/tsconfig.json +12 -0
  49. package/templates/top-down/vite.config.ts +5 -0
  50. package/templates/ui-app/README.md +17 -0
  51. package/templates/ui-app/index.html +25 -0
  52. package/templates/ui-app/package.json +20 -0
  53. package/templates/ui-app/public/assets/.gitkeep +0 -0
  54. package/templates/ui-app/src/main.ts +18 -0
  55. package/templates/ui-app/src/scenes/SettingsScene.ts +136 -0
  56. package/templates/ui-app/tsconfig.json +12 -0
  57. package/templates/ui-app/vite.config.ts +5 -0
@@ -6,7 +6,7 @@ export class Player extends Graphics {
6
6
  public constructor() {
7
7
  super();
8
8
  // Circle drawn at local origin so the node position is the visual center
9
- this.fillColor = Color.tomato;
9
+ this.fillColor = new Color(0xff6347);
10
10
  this.drawCircle(0, 0, 20);
11
11
  }
12
12
  }
@@ -1,33 +1,27 @@
1
1
  import { Color, Keyboard, Scene, Text } from '@codexo/exojs';
2
- import type { RenderingContext } from '@codexo/exojs';
2
+
3
3
  import { GameScene } from './GameScene';
4
4
 
5
- export class GameOverScene extends Scene {
6
- private _label!: Text;
5
+ export interface GameOverData {
6
+ readonly score: number;
7
+ }
7
8
 
8
- public constructor(private readonly _score: number) {
9
- super();
10
- }
9
+ export class GameOverScene extends Scene<GameOverData> {
10
+ private _label!: Text;
11
11
 
12
- public override init(): void {
12
+ public override init(data: Readonly<GameOverData>): void {
13
13
  const { width, height } = this.app!.canvas;
14
14
 
15
- this._label = new Text(
16
- `Game Over\nScore: ${this._score}\n\nPress Space to restart`,
17
- { align: 'center', fillColor: Color.white, fontSize: 26 },
18
- );
15
+ this.app!.clearColor.set(48, 10, 10);
16
+
17
+ this._label = new Text(`Game Over\nScore: ${data.score}\n\nPress Space to restart`, { align: 'center', fillColor: Color.white, fontSize: 26 });
19
18
  this._label.setAnchor(0.5);
20
19
  this._label.setPosition(width / 2, height / 2);
21
20
 
22
21
  this.addChild(this._label);
23
22
 
24
23
  this.inputs.onTrigger(Keyboard.Space, () => {
25
- void this.app!.scene.setScene(new GameScene());
24
+ void this.app!.scenes.change(GameScene);
26
25
  });
27
26
  }
28
-
29
- public override draw(context: RenderingContext): void {
30
- context.backend.clear(new Color(48, 10, 10));
31
- context.render(this.root);
32
- }
33
27
  }
@@ -1,5 +1,6 @@
1
+ import type { Seconds } from '@codexo/exojs';
1
2
  import { Color, Keyboard, Scene, Text } from '@codexo/exojs';
2
- import type { RenderingContext, Time } from '@codexo/exojs';
3
+
3
4
  import { Player } from '../objects/Player';
4
5
  import { GameOverScene } from './GameOverScene';
5
6
 
@@ -12,6 +13,11 @@ export class GameScene extends Scene {
12
13
  public override init(): void {
13
14
  const { width, height } = this.app!.canvas;
14
15
 
16
+ // Each scene owns its background. The engine clears to `app.clearColor`
17
+ // before `draw` runs, and `init` fires once per activation - so coming
18
+ // back from the game-over screen repaints the frame in this colour.
19
+ this.app!.clearColor.set(18, 28, 48);
20
+
15
21
  this._player = new Player();
16
22
  this._player.setPosition(width / 2, height / 2);
17
23
 
@@ -22,44 +28,71 @@ export class GameScene extends Scene {
22
28
  this.addChild(this._scoreText);
23
29
 
24
30
  // WASD + arrow keys
25
- this.inputs.onActive(Keyboard.W, () => { this._move.up = 1; });
26
- this.inputs.onStop(Keyboard.W, () => { this._move.up = 0; });
27
- this.inputs.onActive(Keyboard.S, () => { this._move.down = 1; });
28
- this.inputs.onStop(Keyboard.S, () => { this._move.down = 0; });
29
- this.inputs.onActive(Keyboard.A, () => { this._move.left = 1; });
30
- this.inputs.onStop(Keyboard.A, () => { this._move.left = 0; });
31
- this.inputs.onActive(Keyboard.D, () => { this._move.right = 1; });
32
- this.inputs.onStop(Keyboard.D, () => { this._move.right = 0; });
33
- this.inputs.onActive(Keyboard.Up, () => { this._move.up = 1; });
34
- this.inputs.onStop(Keyboard.Up, () => { this._move.up = 0; });
35
- this.inputs.onActive(Keyboard.Down, () => { this._move.down = 1; });
36
- this.inputs.onStop(Keyboard.Down, () => { this._move.down = 0; });
37
- this.inputs.onActive(Keyboard.Left, () => { this._move.left = 1; });
38
- this.inputs.onStop(Keyboard.Left, () => { this._move.left = 0; });
39
- this.inputs.onActive(Keyboard.Right, () => { this._move.right = 1; });
40
- this.inputs.onStop(Keyboard.Right, () => { this._move.right = 0; });
31
+ this.inputs.onActive(Keyboard.W, () => {
32
+ this._move.up = 1;
33
+ });
34
+ this.inputs.onStop(Keyboard.W, () => {
35
+ this._move.up = 0;
36
+ });
37
+ this.inputs.onActive(Keyboard.S, () => {
38
+ this._move.down = 1;
39
+ });
40
+ this.inputs.onStop(Keyboard.S, () => {
41
+ this._move.down = 0;
42
+ });
43
+ this.inputs.onActive(Keyboard.A, () => {
44
+ this._move.left = 1;
45
+ });
46
+ this.inputs.onStop(Keyboard.A, () => {
47
+ this._move.left = 0;
48
+ });
49
+ this.inputs.onActive(Keyboard.D, () => {
50
+ this._move.right = 1;
51
+ });
52
+ this.inputs.onStop(Keyboard.D, () => {
53
+ this._move.right = 0;
54
+ });
55
+ this.inputs.onActive(Keyboard.Up, () => {
56
+ this._move.up = 1;
57
+ });
58
+ this.inputs.onStop(Keyboard.Up, () => {
59
+ this._move.up = 0;
60
+ });
61
+ this.inputs.onActive(Keyboard.Down, () => {
62
+ this._move.down = 1;
63
+ });
64
+ this.inputs.onStop(Keyboard.Down, () => {
65
+ this._move.down = 0;
66
+ });
67
+ this.inputs.onActive(Keyboard.Left, () => {
68
+ this._move.left = 1;
69
+ });
70
+ this.inputs.onStop(Keyboard.Left, () => {
71
+ this._move.left = 0;
72
+ });
73
+ this.inputs.onActive(Keyboard.Right, () => {
74
+ this._move.right = 1;
75
+ });
76
+ this.inputs.onStop(Keyboard.Right, () => {
77
+ this._move.right = 0;
78
+ });
41
79
 
42
80
  this.inputs.onTrigger(Keyboard.Escape, () => {
43
- void this.app!.scene.setScene(new GameOverScene(Math.floor(this._elapsed)));
81
+ void this.app!.scenes.change(GameOverScene, { data: { score: Math.floor(this._elapsed) } });
44
82
  });
45
83
  }
46
84
 
47
- public override update(delta: Time): void {
85
+ public override update(delta: Seconds): void {
48
86
  const dx = this._move.right - this._move.left;
49
87
  const dy = this._move.down - this._move.up;
50
88
 
51
89
  if (dx !== 0 || dy !== 0) {
52
90
  const len = Math.sqrt(dx * dx + dy * dy);
53
- const speed = this._player.speed * delta.seconds;
91
+ const speed = this._player.speed * delta;
54
92
  this._player.move((dx / len) * speed, (dy / len) * speed);
55
93
  }
56
94
 
57
- this._elapsed += delta.seconds;
95
+ this._elapsed += delta;
58
96
  this._scoreText.text = `Score: ${Math.floor(this._elapsed)}`;
59
97
  }
60
-
61
- public override draw(context: RenderingContext): void {
62
- context.backend.clear();
63
- context.render(this.root);
64
- }
65
98
  }
@@ -1,12 +1,22 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>ExoJS App</title>
7
7
  <style>
8
- * { margin: 0; padding: 0; box-sizing: border-box; }
9
- body { background: #000; display: flex; justify-content: center; align-items: center; min-height: 100vh; }
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ }
13
+ body {
14
+ background: #000;
15
+ display: flex;
16
+ justify-content: center;
17
+ align-items: center;
18
+ min-height: 100vh;
19
+ }
10
20
  </style>
11
21
  </head>
12
22
  <body>
@@ -2,16 +2,19 @@
2
2
  "name": "exo-app",
3
3
  "version": "0.0.1",
4
4
  "type": "module",
5
+ "engines": {
6
+ "node": ">=24"
7
+ },
5
8
  "scripts": {
6
9
  "dev": "vite",
7
10
  "build": "tsc && vite build",
8
11
  "preview": "vite preview"
9
12
  },
10
13
  "dependencies": {
11
- "@codexo/exojs": "^0.12.0"
14
+ "@codexo/exojs": "lockstep"
12
15
  },
13
16
  "devDependencies": {
14
- "typescript": "^5.8.0",
15
- "vite": "^6.0.0"
17
+ "typescript": "^7.0.2",
18
+ "vite": "^8.3.1"
16
19
  }
17
20
  }
@@ -1,16 +1,17 @@
1
1
  // #region guide:minimal-main
2
2
  import { Application, Color } from '@codexo/exojs';
3
+
3
4
  import { MainScene } from './scenes/MainScene';
4
5
 
5
6
  const app = new Application({
7
+ scenes: { MainScene },
6
8
  canvas: {
7
9
  width: 800,
8
10
  height: 600,
11
+ mount: 'body',
9
12
  },
10
- clearColor: Color.cornflowerBlue,
13
+ clearColor: new Color(0x6495ed),
11
14
  });
12
15
 
13
- document.body.append(app.canvas);
14
-
15
- app.start(new MainScene());
16
+ await app.start(MainScene);
16
17
  // #endregion guide:minimal-main
@@ -1,6 +1,6 @@
1
1
  // #region guide:minimal-scene
2
+ import type { Seconds } from '@codexo/exojs';
2
3
  import { Color, Graphics, Scene } from '@codexo/exojs';
3
- import type { RenderingContext, Time } from '@codexo/exojs';
4
4
 
5
5
  export class MainScene extends Scene {
6
6
  private readonly _box = new Graphics();
@@ -15,13 +15,8 @@ export class MainScene extends Scene {
15
15
  this.addChild(this._box);
16
16
  }
17
17
 
18
- public override update(delta: Time): void {
19
- this._box.rotate(delta.seconds * 90);
20
- }
21
-
22
- public override draw(context: RenderingContext): void {
23
- context.backend.clear();
24
- context.render(this.root);
18
+ public override update(delta: Seconds): void {
19
+ this._box.rotate(delta * 90);
25
20
  }
26
21
  }
27
22
  // #endregion guide:minimal-scene
@@ -0,0 +1,13 @@
1
+ # Platformer template
2
+
3
+ Side-scrolling starter wired to `@codexo/exojs-physics`: a dynamic player body, static level geometry, camera follow, and the two timing rules that make a jump feel right.
4
+
5
+ ## Where things are
6
+
7
+ - `src/scenes/PlatformerScene.ts` — level layout, the physics world, and the camera.
8
+ - `src/objects/Player.ts` — movement, jumping, and the ground check.
9
+ - `public/assets/` — the sprite atlases.
10
+
11
+ ## Art
12
+
13
+ The sprite atlases are from Kenney's _New Platformer Pack_, released under CC0. `public/assets/ART-LICENSE.txt` is the pack's own licence file. You can replace or delete the art without any attribution obligation.
@@ -0,0 +1,25 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>ExoJS Platformer</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ }
13
+ body {
14
+ background: #10141f;
15
+ display: flex;
16
+ justify-content: center;
17
+ align-items: center;
18
+ min-height: 100vh;
19
+ }
20
+ </style>
21
+ </head>
22
+ <body>
23
+ <script type="module" src="/src/main.ts"></script>
24
+ </body>
25
+ </html>
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "exo-platformer",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "engines": {
6
+ "node": ">=24"
7
+ },
8
+ "scripts": {
9
+ "dev": "vite",
10
+ "build": "tsc && vite build",
11
+ "preview": "vite preview"
12
+ },
13
+ "dependencies": {
14
+ "@codexo/exojs": "lockstep",
15
+ "@codexo/exojs-physics": "lockstep"
16
+ },
17
+ "devDependencies": {
18
+ "typescript": "^7.0.2",
19
+ "vite": "^8.3.1"
20
+ }
21
+ }
@@ -0,0 +1,28 @@
1
+
2
+
3
+ New Platformer Pack (1.1)
4
+
5
+ Created/distributed by Kenney (www.kenney.nl)
6
+ Creation date: 03-12-2025
7
+
8
+ ------------------------------
9
+
10
+ License: (Creative Commons Zero, CC0)
11
+ http://creativecommons.org/publicdomain/zero/1.0/
12
+
13
+ You can use this content for personal, educational, and commercial purposes.
14
+
15
+ Support by crediting 'Kenney' or 'www.kenney.nl' (this is not a requirement)
16
+
17
+ ------------------------------
18
+
19
+ • Website : www.kenney.nl
20
+ • Donate : www.kenney.nl/donate
21
+
22
+ • Patreon : patreon.com/kenney
23
+
24
+ Follow on social media for updates:
25
+
26
+ • Twitter: twitter.com/KenneyNL
27
+ • BlueSky: kenney.bsky.social
28
+ • Instagram: instagram.com/kenney_nl