@zakkster/lite-tools 2.0.8 → 2.0.10
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/LiteEngine.d.ts +4 -4
- package/LiteEngine.js +7 -7
- package/README.md +2 -2
- package/package.json +1 -1
package/LiteEngine.d.ts
CHANGED
|
@@ -113,9 +113,9 @@ export { Seek, Flee, Wander, Arrive, Pursuit, Evade, PathFollow, Separation, Ali
|
|
|
113
113
|
export { BitmapFont } from '@zakkster/lite-bmfont';
|
|
114
114
|
export { InputPoller } from '@zakkster/lite-gamepad';
|
|
115
115
|
export { CinematicCamera } from '@zakkster/lite-camera';
|
|
116
|
-
export {
|
|
116
|
+
export { SpatialGrid } from '@zakkster/lite-spatial';
|
|
117
117
|
export { testPolygonPolygon, translatePoly, rotatePoly } from '@zakkster/lite-sat';
|
|
118
|
-
export {
|
|
118
|
+
export { Pathfinder } from '@zakkster/lite-path';
|
|
119
119
|
export { ShadowCaster } from '@zakkster/lite-shadow';
|
|
120
120
|
export { WFC } from '@zakkster/lite-wfc';
|
|
121
121
|
export { AudioPool } from '@zakkster/lite-audio-pool';
|
|
@@ -147,7 +147,7 @@ import type {FPSMeter} from 'lite-fps-meter';
|
|
|
147
147
|
import type {PointerTracker} from 'lite-pointer-tracker';
|
|
148
148
|
import type {BitmapFont} from '@zakkster/lite-bmfont';
|
|
149
149
|
import type {CinematicCamera} from '@zakkster/lite-camera';
|
|
150
|
-
import type {
|
|
150
|
+
import type {SpatialGrid} from '@zakkster/lite-spatial';
|
|
151
151
|
import type {EmberEngine} from '@zakkster/lite-embers';
|
|
152
152
|
import type {SmokeEngine} from '@zakkster/lite-smoke';
|
|
153
153
|
import type {RainEngine} from '@zakkster/lite-rain';
|
|
@@ -338,7 +338,7 @@ export interface DungeonGeneratorResult extends Destroyable {
|
|
|
338
338
|
grid: Uint8Array;
|
|
339
339
|
width: number;
|
|
340
340
|
height: number;
|
|
341
|
-
spatial:
|
|
341
|
+
spatial: SpatialGrid;
|
|
342
342
|
isWalkable(x: number, y: number): boolean;
|
|
343
343
|
findPath(sx: number, sy: number, ex: number, ey: number): Array<{ x: number; y: number }> | null;
|
|
344
344
|
renderToCanvas(ctx: CanvasRenderingContext2D, tileSize?: number): void;
|
package/LiteEngine.js
CHANGED
|
@@ -114,9 +114,9 @@ export {
|
|
|
114
114
|
export {BitmapFont} from '@zakkster/lite-bmfont';
|
|
115
115
|
export {InputPoller} from '@zakkster/lite-gamepad';
|
|
116
116
|
export {CinematicCamera} from '@zakkster/lite-camera';
|
|
117
|
-
export {
|
|
117
|
+
export {SpatialGrid} from '@zakkster/lite-spatial';
|
|
118
118
|
export {testPolygonPolygon, translatePoly, rotatePoly} from '@zakkster/lite-sat';
|
|
119
|
-
export {
|
|
119
|
+
export {Pathfinder} from '@zakkster/lite-path';
|
|
120
120
|
export {ShadowCaster} from '@zakkster/lite-shadow';
|
|
121
121
|
export {WFC} from '@zakkster/lite-wfc';
|
|
122
122
|
export {AudioPool} from '@zakkster/lite-audio-pool';
|
|
@@ -173,8 +173,8 @@ import {Flock, Wander, Separation, Alignment, Cohesion} from '@zakkster/lite-ste
|
|
|
173
173
|
import {BitmapFont} from '@zakkster/lite-bmfont';
|
|
174
174
|
import {InputPoller} from '@zakkster/lite-gamepad';
|
|
175
175
|
import {CinematicCamera} from '@zakkster/lite-camera';
|
|
176
|
-
import {
|
|
177
|
-
import {
|
|
176
|
+
import {SpatialGrid} from '@zakkster/lite-spatial';
|
|
177
|
+
import {Pathfinder} from '@zakkster/lite-path';
|
|
178
178
|
import {WFC} from '@zakkster/lite-wfc';
|
|
179
179
|
import {AudioPool} from '@zakkster/lite-audio-pool';
|
|
180
180
|
import {FireworksEngine} from '@zakkster/lite-fireworks';
|
|
@@ -1069,7 +1069,7 @@ export const Recipes = {
|
|
|
1069
1069
|
const {width = 32, height = 32, seed = Date.now()} = options;
|
|
1070
1070
|
const rng = new Random(seed);
|
|
1071
1071
|
const grid = new Uint8Array(width * height); // 0=wall, 1=floor
|
|
1072
|
-
const spatial = new
|
|
1072
|
+
const spatial = new SpatialGrid(width * 4, height * 4, 32);
|
|
1073
1073
|
|
|
1074
1074
|
// Simple noise-based dungeon
|
|
1075
1075
|
for (let y = 0; y < height; y++) {
|
|
@@ -1092,7 +1092,7 @@ export const Recipes = {
|
|
|
1092
1092
|
}
|
|
1093
1093
|
|
|
1094
1094
|
function findPath(sx, sy, ex, ey) {
|
|
1095
|
-
const finder = new
|
|
1095
|
+
const finder = new Pathfinder(width, height, (x, y) => isWalkable(x, y));
|
|
1096
1096
|
return finder.find(sx, sy, ex, ey);
|
|
1097
1097
|
}
|
|
1098
1098
|
|
|
@@ -1195,7 +1195,7 @@ export const Recipes = {
|
|
|
1195
1195
|
const ctx = canvas.getContext('2d');
|
|
1196
1196
|
const rng = new Random(seed);
|
|
1197
1197
|
const w = canvas.width, h = canvas.height;
|
|
1198
|
-
const spatial = new
|
|
1198
|
+
const spatial = new SpatialGrid(w, h, 64);
|
|
1199
1199
|
const agents = [];
|
|
1200
1200
|
|
|
1201
1201
|
for (let i = 0; i < count; i++) {
|
package/README.md
CHANGED
|
@@ -467,7 +467,7 @@ dungeon.spatial.insert(enemy, enemy.x, enemy.y, 8, 8);
|
|
|
467
467
|
const nearby = dungeon.spatial.query(player.x - 64, player.y - 64, 128, 128);
|
|
468
468
|
```
|
|
469
469
|
|
|
470
|
-
**Composes:** `Random` + `
|
|
470
|
+
**Composes:** `Random` + `SpatialGrid` + `Pathfinder`
|
|
471
471
|
|
|
472
472
|
</details>
|
|
473
473
|
|
|
@@ -538,7 +538,7 @@ boids.agents.forEach(a => {
|
|
|
538
538
|
});
|
|
539
539
|
```
|
|
540
540
|
|
|
541
|
-
**Composes:** `
|
|
541
|
+
**Composes:** `SpatialGrid` (O(1) neighbor lookup) + separation/alignment/cohesion forces + `Random`
|
|
542
542
|
|
|
543
543
|
</details>
|
|
544
544
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zakkster/lite-tools",
|
|
3
3
|
"author": "Zahary Shinikchiev <shinikchiev@yahoo.com>",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.10",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "The standard library for high-performance web presentation — 45+ micro-libraries, 24 recipes, zero-GC, deterministic, tree-shakeable.",
|
|
7
7
|
"type": "module",
|