Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(examples): repair broken + stale examples, register lighting-2d

esenginec35c6cfea761
diff --git a/examples/ASSETS.md b/examples/ASSETS.md
index 58b3bc256..6095bd686 100644
--- a/examples/ASSETS.md
+++ b/examples/ASSETS.md
@@ -9,11 +9,10 @@ starting point for a real game. This credit is a courtesy, not an obligation.
| Pack | License | Used by |
| --- | --- | --- |
-| [Platformer Art Deluxe](https://kenney.nl/assets/platformer-art-deluxe) | CC0 | platformer, sprite-animation (walk/idle frames), hello-world (gem), physics-playground (crate) |
+| [Platformer Art Deluxe](https://kenney.nl/assets/platformer-art-deluxe) | CC0 | platformer, sprite-animation (walk/idle frames), hello-world (gem) |
| [Space Shooter Remastered](https://kenney.nl/assets/space-shooter-remastered) | CC0 | space-shooter (ships, lasers, enemies, life icon, starfield), input-demo (cursor), sprite-rendering (star) |
| [Simple Space](https://kenney.nl/assets/simple-space) | CC0 | input-demo (player ship) |
| [Particle Pack](https://kenney.nl/assets/particle-pack) | CC0 | particle-demo, space-shooter (explosion) |
-| [Physics Assets](https://kenney.nl/assets/physics-assets) | CC0 | physics-playground (ball) |
| [UI Pack](https://kenney.nl/assets/ui-pack) | CC0 | sprite-rendering (arrow) |
| [Pixel Platformer](https://kenney.nl/assets/pixel-platformer) | CC0 | tilemap-demo (`tileset.png` terrain atlas; `props.png` is a handful of its tiles repacked into a second tileset) |
diff --git a/examples/README.md b/examples/README.md
index e587b09ce..7801384f1 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -12,7 +12,7 @@ for your own game.
| Example | Tag | What it shows |
| --- | --- | --- |
-| **hello-world** | Basics | The smallest project — one rotating, color-pulsing sprite. |
+| **hello-world** | Basics | A minimal project — rotating, color-pulsing sprites. |
| **ecs-basics** | ECS | Spawn, move, bounce and expire entities: the core ECS loop. |
| **event-system** | ECS | Decoupled gameplay with typed events — collect, score, react. |
| **sprite-rendering** | Rendering | Draw sprites with rotation, tint and flipping. |
@@ -25,6 +25,7 @@ for your own game.
| **physics-spinner** | Physics | Revolute joints and continuous rotation. |
| **particle-demo** | Effects | A configurable particle emitter with additive blending. |
| **postprocess-effects** | Effects | Full-screen post-processing: bloom, vignette, color grading. |
+| **lighting-2d** | Rendering | 2D lights and shadow casters with a normal-mapped, Lit-2D material. |
| **tilemap-demo** | Tilemap | Two scenes: a Tiled `.tmj` import and an engine-native `.estileset` — multi-tileset, parallax, animated water, per-tile collision. |
| **ui-controls** | UI | Buttons, sliders, toggles and progress bars. |
| **ui-interaction** | UI | Dragging, focus and pointer interaction. |
diff --git a/examples/event-system/src/systems/collect.ts b/examples/event-system/src/systems/collect.ts
index 4f201928d..e295e2568 100644
--- a/examples/event-system/src/systems/collect.ts
+++ b/examples/event-system/src/systems/collect.ts
@@ -5,14 +5,10 @@ import {
import { Collectible } from '../components';
import { CollectEventDef } from '../events';
-const COLLECT_LIFETIME = 5;
-
export const collectSystem = defineSystem(
[Query(Transform, Sprite, Collectible), Res(Time), Commands(), EventWriter(CollectEventDef)],
(query, time, cmds, writer) => {
for (const [entity, _transform, sprite, collectible] of query) {
- const age = COLLECT_LIFETIME - (sprite.color.a > 0.1 ? COLLECT_LIFETIME : 0);
-
sprite.color.a -= time.delta * 0.2;
if (sprite.color.a <= 0) {
diff --git a/examples/hello-world/project.esproject b/examples/hello-world/project.esproject
index 5194e2868..f54cfa2df 100644
--- a/examples/hello-world/project.esproject
+++ b/examples/hello-world/project.esproject
@@ -1,7 +1,7 @@
{
"formatVersion": "1",
"name": "Hello World",
- "description": "A rotating, color-pulsing sprite — the smallest possible Estella project.",
+ "description": "Rotating, color-pulsing sprites — a minimal Estella project.",
"tag": "Basics",
"version": "0.1.0",
"defaultScene": "assets/scenes/main.esscene",
diff --git a/examples/lighting-2d/assets/scenes/main.esscene.meta b/examples/lighting-2d/assets/scenes/main.esscene.meta
new file mode 100644
index 000000000..224b57310
--- /dev/null
+++ b/examples/lighting-2d/assets/scenes/main.esscene.meta
@@ -0,0 +1,8 @@
+{
+ "uuid": "13f10cae-befe-4371-bae0-0c4685bcd0dd",
+ "version": "2.0",
+ "type": "scene",
+ "importer": {
+ "autoMigrate": true
+ }
+}
diff --git a/examples/physics-playground/assets/textures/ball.png b/examples/physics-playground/assets/textures/ball.png
deleted file mode 100644
index e9f6db0e2..000000000
Binary files a/examples/physics-playground/assets/textures/ball.png and /dev/null differ
diff --git a/examples/physics-playground/assets/textures/ball.png.meta b/examples/physics-playground/assets/textures/ball.png.meta
deleted file mode 100644
index 243c063e0..000000000
--- a/examples/physics-playground/assets/textures/ball.png.meta
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "uuid": "0477f2e4-d640-4a8e-b696-36f52b7583df",
- "version": "2.0",
- "type": "texture",
- "importer": {
- "maxSize": 2048,
- "filterMode": "linear",
- "wrapMode": "repeat",
- "premultiplyAlpha": false,
- "sliceBorder": {
- "left": 0,
- "right": 0,
- "top": 0,
- "bottom": 0
- }
- }
-}
\ No newline at end of file
diff --git a/examples/physics-playground/assets/textures/crate.png b/examples/physics-playground/assets/textures/crate.png
deleted file mode 100644
index 7471ed717..000000000
Binary files a/examples/physics-playground/assets/textures/crate.png and /dev/null differ
diff --git a/examples/physics-playground/assets/textures/crate.png.meta b/examples/physics-playground/assets/textures/crate.png.meta
deleted file mode 100644
index 41dbc122c..000000000
--- a/examples/physics-playground/assets/textures/crate.png.meta
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "uuid": "88be0710-ab45-4377-ac76-166aecfbd56f",
- "version": "2.0",
- "type": "texture",
- "importer": {
- "maxSize": 2048,
- "filterMode": "linear",
- "wrapMode": "repeat",
- "premultiplyAlpha": false,
- "sliceBorder": {
- "left": 0,
- "right": 0,
- "top": 0,
- "bottom": 0
- }
- }
-}
\ No newline at end of file
diff --git a/examples/physics-spinner/src/systems/spawn.ts b/examples/physics-spinner/src/systems/spawn.ts
index a6693c79e..ea067f474 100644
--- a/examples/physics-spinner/src/systems/spawn.ts
+++ b/examples/physics-spinner/src/systems/spawn.ts
@@ -5,7 +5,7 @@ import {
} from 'esengine';
import { SpawnMarker } from '../components';
-const BODY_COUNT = 6076;
+const BODY_COUNT = 150;
const PPU = 100;
const GRID_LEFT = -23;
const GRID_RIGHT = 23;
diff --git a/examples/space-shooter/src/systems/hud.ts b/examples/space-shooter/src/systems/hud.ts
index 64cfd9047..45b8d6cb8 100644
--- a/examples/space-shooter/src/systems/hud.ts
+++ b/examples/space-shooter/src/systems/hud.ts
@@ -1,12 +1,12 @@
import {
defineSystem, Query, Mut, Res, ResMut, Commands,
- Input, Text, Image, Transform,
+ Input, Text, UIVisual, Transform,
} from 'esengine';
import { Player, Health, ScoreDisplay, HealthHeart, GameOverScreen, Enemy, Bullet, Explosion } from '../components';
import { GameState, PLAYER_START_Y } from '../resources';
export const hudSystem = defineSystem(
- [Res(GameState), Query(Mut(Text), ScoreDisplay), Query(Health, Player), Query(Mut(Image), HealthHeart)],
+ [Res(GameState), Query(Mut(Text), ScoreDisplay), Query(Health, Player), Query(Mut(UIVisual), HealthHeart)],
(state, scoreQuery, playerQuery, heartQuery) => {
for (const [_entity, text] of scoreQuery) {
text.content = `SCORE: ${state.score}`;
@@ -14,8 +14,8 @@ export const hudSystem = defineSystem(
for (const [_entity, health] of playerQuery) {
let heartIndex = 0;
- for (const [_hEntity, image] of heartQuery) {
- image.color = heartIndex < health.value
+ for (const [_hEntity, visual] of heartQuery) {
+ visual.color = heartIndex < health.value
? { r: 1, g: 1, b: 1, a: 1 }
: { r: 0.3, g: 0.3, b: 0.3, a: 0.4 };
heartIndex++;
diff --git a/examples/sprite-rendering/assets/scenes/main.esscene b/examples/sprite-rendering/assets/scenes/main.esscene
index 413e3234c..505f890f3 100644
--- a/examples/sprite-rendering/assets/scenes/main.esscene
+++ b/examples/sprite-rendering/assets/scenes/main.esscene
@@ -213,7 +213,7 @@
"components": [
{ "type": "Transform", "data": { "position": { "x": -90, "y": -200, "z": 0 } } },
{ "type": "Sprite", "data": { "size": { "x": 50, "y": 30 }, "color": { "r": 0.4, "g": 0.8, "b": 1, "a": 1 }, "layer": 5, "texture": "@uuid:d7cfc683-b474-4c6a-bedf-c5149593510a" } },
- { "type": "FlipDemo", "data": {} }
+ { "type": "Spin", "data": {} }
],
"visible": true
},
@@ -225,7 +225,7 @@
"components": [
{ "type": "Transform", "data": { "position": { "x": -10, "y": -200, "z": 0 } } },
{ "type": "Sprite", "data": { "size": { "x": 50, "y": 30 }, "color": { "r": 0.4, "g": 0.8, "b": 1, "a": 1 }, "flipX": true, "layer": 5, "texture": "@uuid:d7cfc683-b474-4c6a-bedf-c5149593510a" } },
- { "type": "FlipDemo", "data": {} }
+ { "type": "Spin", "data": {} }
],
"visible": true
},
@@ -237,7 +237,7 @@
"components": [
{ "type": "Transform", "data": { "position": { "x": 70, "y": -200, "z": 0 } } },
{ "type": "Sprite", "data": { "size": { "x": 50, "y": 30 }, "color": { "r": 0.4, "g": 0.8, "b": 1, "a": 1 }, "flipY": true, "layer": 5, "texture": "@uuid:d7cfc683-b474-4c6a-bedf-c5149593510a" } },
- { "type": "FlipDemo", "data": {} }
+ { "type": "Spin", "data": {} }
],
"visible": true
},
@@ -249,7 +249,7 @@
"components": [
{ "type": "Transform", "data": { "position": { "x": 150, "y": -200, "z": 0 } } },
{ "type": "Sprite", "data": { "size": { "x": 50, "y": 30 }, "color": { "r": 0.4, "g": 0.8, "b": 1, "a": 1 }, "flipX": true, "flipY": true, "layer": 5, "texture": "@uuid:d7cfc683-b474-4c6a-bedf-c5149593510a" } },
- { "type": "FlipDemo", "data": {} }
+ { "type": "Spin", "data": {} }
],
"visible": true
}
diff --git a/examples/sprite-rendering/src/components.ts b/examples/sprite-rendering/src/components.ts
index 49725328b..5dc102db5 100644
--- a/examples/sprite-rendering/src/components.ts
+++ b/examples/sprite-rendering/src/components.ts
@@ -14,4 +14,4 @@ export const Orbit = defineComponent('Orbit', {
angle: 0,
});
-export const FlipDemo = defineTag('FlipDemo');
+export const Spin = defineTag('Spin');
diff --git a/examples/sprite-rendering/src/main.ts b/examples/sprite-rendering/src/main.ts
index 87b020653..845abf07e 100644
--- a/examples/sprite-rendering/src/main.ts
+++ b/examples/sprite-rendering/src/main.ts
@@ -1,8 +1,8 @@
import { addSystemToSchedule, Schedule } from 'esengine';
import './components';
-import { waveSystem, orbitSystem, flipSystem } from './systems/animate';
+import { waveSystem, orbitSystem, spinSystem } from './systems/animate';
addSystemToSchedule(Schedule.Update, waveSystem);
addSystemToSchedule(Schedule.Update, orbitSystem);
-addSystemToSchedule(Schedule.Update, flipSystem);
+addSystemToSchedule(Schedule.Update, spinSystem);
diff --git a/examples/sprite-rendering/src/systems/animate.ts b/examples/sprite-rendering/src/systems/animate.ts
index 84d9781a9..9acbe81b6 100644
--- a/examples/sprite-rendering/src/systems/animate.ts
+++ b/examples/sprite-rendering/src/systems/animate.ts
@@ -2,7 +2,7 @@ import {
defineSystem, Query, Mut, Res, Time,
Transform, Sprite,
} from 'esengine';
-import { Wave, Orbit, FlipDemo } from '../components';
+import { Wave, Orbit, Spin } from '../components';
export const waveSystem = defineSystem(
[Query(Mut(Transform), Wave), Res(Time)],
@@ -26,13 +26,13 @@ export const orbitSystem = defineSystem(
{ name: 'OrbitSystem' }
);
-export const flipSystem = defineSystem(
- [Query(Mut(Transform), FlipDemo), Res(Time)],
+export const spinSystem = defineSystem(
+ [Query(Mut(Transform), Spin), Res(Time)],
(query, time) => {
for (const [_entity, transform] of query) {
- const bounce = Math.sin(time.elapsed * 2) * 5;
- transform.position.y += bounce * time.delta;
+ const angle = time.elapsed * 1.5;
+ transform.rotation = { w: Math.cos(angle), x: 0, y: 0, z: Math.sin(angle) };
}
},
- { name: 'FlipSystem' }
+ { name: 'SpinSystem' }
);