cubeforge 0.1.2 → 0.1.3
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.d.mts +619 -0
- package/dist/{index.js → index.mjs} +758 -917
- package/package.json +10 -10
- package/dist/components/Animation.d.ts +0 -14
- package/dist/components/BoxCollider.d.ts +0 -17
- package/dist/components/Camera2D.d.ts +0 -27
- package/dist/components/Checkpoint.d.ts +0 -18
- package/dist/components/CircleCollider.d.ts +0 -11
- package/dist/components/DevTools.d.ts +0 -15
- package/dist/components/Entity.d.ts +0 -10
- package/dist/components/Game.d.ts +0 -52
- package/dist/components/MovingPlatform.d.ts +0 -22
- package/dist/components/ParallaxLayer.d.ts +0 -28
- package/dist/components/ParticleEmitter.d.ts +0 -26
- package/dist/components/RigidBody.d.ts +0 -15
- package/dist/components/ScreenFlash.d.ts +0 -4
- package/dist/components/Script.d.ts +0 -11
- package/dist/components/Sprite.d.ts +0 -22
- package/dist/components/SquashStretch.d.ts +0 -8
- package/dist/components/Tilemap.d.ts +0 -58
- package/dist/components/Transform.d.ts +0 -9
- package/dist/components/World.d.ts +0 -10
- package/dist/components/particlePresets.d.ts +0 -13
- package/dist/components/spriteAtlas.d.ts +0 -8
- package/dist/context.d.ts +0 -22
- package/dist/hooks/useCamera.d.ts +0 -37
- package/dist/hooks/useContact.d.ts +0 -57
- package/dist/hooks/useEntity.d.ts +0 -2
- package/dist/hooks/useEvents.d.ts +0 -3
- package/dist/hooks/useGame.d.ts +0 -2
- package/dist/hooks/useInput.d.ts +0 -2
- package/dist/hooks/useInputMap.d.ts +0 -25
- package/dist/hooks/usePlatformerController.d.ts +0 -32
- package/dist/hooks/useSnapshot.d.ts +0 -42
- package/dist/hooks/useTopDownMovement.d.ts +0 -22
- package/dist/index.d.ts +0 -60
- package/dist/systems/debugSystem.d.ts +0 -10
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cubeforge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "React-first 2D browser game engine",
|
|
5
|
-
"main": "./
|
|
5
|
+
"main": "./src/index.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"typecheck": "tsc --noEmit",
|
|
8
|
-
"build": "
|
|
8
|
+
"build": "tsup"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"main": "./dist/index.js",
|
|
@@ -24,6 +24,13 @@
|
|
|
24
24
|
"react": "^18.0.0",
|
|
25
25
|
"react-dom": "^18.0.0"
|
|
26
26
|
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@cubeforge/core": "workspace:*",
|
|
29
|
+
"@cubeforge/input": "workspace:*",
|
|
30
|
+
"@cubeforge/physics": "workspace:*",
|
|
31
|
+
"@cubeforge/renderer": "workspace:*",
|
|
32
|
+
"tsup": "^8.0.0"
|
|
33
|
+
},
|
|
27
34
|
"keywords": [
|
|
28
35
|
"game-engine",
|
|
29
36
|
"react",
|
|
@@ -35,12 +42,5 @@
|
|
|
35
42
|
"repository": {
|
|
36
43
|
"type": "git",
|
|
37
44
|
"url": "https://github.com/1homsi/cubeforge"
|
|
38
|
-
},
|
|
39
|
-
"types": "./dist/index.d.ts",
|
|
40
|
-
"exports": {
|
|
41
|
-
".": {
|
|
42
|
-
"import": "./dist/index.js",
|
|
43
|
-
"types": "./dist/index.d.ts"
|
|
44
|
-
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
interface AnimationProps {
|
|
2
|
-
/** Frame indices to play (indexes into the sprite sheet) */
|
|
3
|
-
frames: number[];
|
|
4
|
-
/** Frames per second, default 12 */
|
|
5
|
-
fps?: number;
|
|
6
|
-
/** Whether to loop, default true */
|
|
7
|
-
loop?: boolean;
|
|
8
|
-
/** Whether currently playing, default true */
|
|
9
|
-
playing?: boolean;
|
|
10
|
-
/** Called once when a non-looping animation finishes playing */
|
|
11
|
-
onComplete?: () => void;
|
|
12
|
-
}
|
|
13
|
-
export declare function Animation({ frames, fps, loop, playing, onComplete }: AnimationProps): null;
|
|
14
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
interface BoxColliderProps {
|
|
2
|
-
width: number;
|
|
3
|
-
height: number;
|
|
4
|
-
offsetX?: number;
|
|
5
|
-
offsetY?: number;
|
|
6
|
-
isTrigger?: boolean;
|
|
7
|
-
layer?: string;
|
|
8
|
-
/** Which layers this collider interacts with. '*' = all (default). */
|
|
9
|
-
mask?: string | string[];
|
|
10
|
-
/**
|
|
11
|
-
* One-way platform: only blocks entities falling onto the top surface.
|
|
12
|
-
* Entities below pass through freely (useful for jump-through ledges).
|
|
13
|
-
*/
|
|
14
|
-
oneWay?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare function BoxCollider({ width, height, offsetX, offsetY, isTrigger, layer, mask, oneWay, }: BoxColliderProps): null;
|
|
17
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
interface Camera2DProps {
|
|
2
|
-
/** String ID of entity to follow */
|
|
3
|
-
followEntity?: string;
|
|
4
|
-
/** Initial camera X position in world space (default 0 = world origin at screen center) */
|
|
5
|
-
x?: number;
|
|
6
|
-
/** Initial camera Y position in world space (default 0 = world origin at screen center) */
|
|
7
|
-
y?: number;
|
|
8
|
-
zoom?: number;
|
|
9
|
-
/** Lerp smoothing factor (0 = instant snap, 0.85 = smooth) */
|
|
10
|
-
smoothing?: number;
|
|
11
|
-
background?: string;
|
|
12
|
-
bounds?: {
|
|
13
|
-
x: number;
|
|
14
|
-
y: number;
|
|
15
|
-
width: number;
|
|
16
|
-
height: number;
|
|
17
|
-
};
|
|
18
|
-
deadZone?: {
|
|
19
|
-
w: number;
|
|
20
|
-
h: number;
|
|
21
|
-
};
|
|
22
|
-
/** World-space offset applied to the follow target (look-ahead, vertical bias, etc.) */
|
|
23
|
-
followOffsetX?: number;
|
|
24
|
-
followOffsetY?: number;
|
|
25
|
-
}
|
|
26
|
-
export declare function Camera2D({ followEntity, x, y, zoom, smoothing, background, bounds, deadZone, followOffsetX, followOffsetY, }: Camera2DProps): null;
|
|
27
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface CheckpointProps {
|
|
3
|
-
x: number;
|
|
4
|
-
y: number;
|
|
5
|
-
width?: number;
|
|
6
|
-
height?: number;
|
|
7
|
-
color?: string;
|
|
8
|
-
/** Called once when a 'player'-tagged entity enters the checkpoint */
|
|
9
|
-
onActivate?: () => void;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* A trigger zone that fires `onActivate` once when a player-tagged entity enters it.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* <Checkpoint x={800} y={450} onActivate={() => setCheckpoint(800)} />
|
|
16
|
-
*/
|
|
17
|
-
export declare function Checkpoint({ x, y, width, height, color, onActivate, }: CheckpointProps): React.ReactElement;
|
|
18
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface CircleColliderProps {
|
|
2
|
-
radius: number;
|
|
3
|
-
offsetX?: number;
|
|
4
|
-
offsetY?: number;
|
|
5
|
-
isTrigger?: boolean;
|
|
6
|
-
layer?: string;
|
|
7
|
-
/** Which layers this collider interacts with. '*' = all (default). */
|
|
8
|
-
mask?: string | string[];
|
|
9
|
-
}
|
|
10
|
-
export declare function CircleCollider({ radius, offsetX, offsetY, isTrigger, layer, mask, }: CircleColliderProps): null;
|
|
11
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { WorldSnapshot } from '@cubeforge/core';
|
|
3
|
-
import type { ECSWorld, GameLoop } from '@cubeforge/core';
|
|
4
|
-
export declare const MAX_DEVTOOLS_FRAMES = 600;
|
|
5
|
-
export interface DevToolsHandle {
|
|
6
|
-
buffer: WorldSnapshot[];
|
|
7
|
-
onFrame?: () => void;
|
|
8
|
-
}
|
|
9
|
-
interface DevToolsProps {
|
|
10
|
-
handle: DevToolsHandle;
|
|
11
|
-
loop: GameLoop;
|
|
12
|
-
ecs: ECSWorld;
|
|
13
|
-
}
|
|
14
|
-
export declare function DevToolsOverlay({ handle, loop, ecs }: DevToolsProps): React.ReactPortal;
|
|
15
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
interface EntityProps {
|
|
3
|
-
/** Optional string ID for cross-entity lookups (e.g. camera follow) */
|
|
4
|
-
id?: string;
|
|
5
|
-
/** Tags for grouping / querying (e.g. ['enemy', 'damageable']) */
|
|
6
|
-
tags?: string[];
|
|
7
|
-
children?: ReactNode;
|
|
8
|
-
}
|
|
9
|
-
export declare function Entity({ id, tags, children }: EntityProps): import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
-
export {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React, { type CSSProperties } from 'react';
|
|
2
|
-
import { type Plugin, type System, type EntityId } from '@cubeforge/core';
|
|
3
|
-
export interface GameControls {
|
|
4
|
-
pause(): void;
|
|
5
|
-
resume(): void;
|
|
6
|
-
reset(): void;
|
|
7
|
-
}
|
|
8
|
-
interface GameProps {
|
|
9
|
-
width?: number;
|
|
10
|
-
height?: number;
|
|
11
|
-
/** Pixels per second squared downward (default 980) */
|
|
12
|
-
gravity?: number;
|
|
13
|
-
/** Enable debug overlay: collider wireframes, FPS, entity count */
|
|
14
|
-
debug?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Canvas scaling strategy (default 'none'):
|
|
17
|
-
* - 'none' — fixed pixel size, no scaling
|
|
18
|
-
* - 'contain' — CSS scale to fit parent while preserving aspect ratio
|
|
19
|
-
* - 'pixel' — nearest-neighbor pixel-art scaling via CSS
|
|
20
|
-
*/
|
|
21
|
-
scale?: 'none' | 'contain' | 'pixel';
|
|
22
|
-
/** Called once the engine is ready — receives pause/resume/reset controls */
|
|
23
|
-
onReady?: (controls: GameControls) => void;
|
|
24
|
-
/** Enable time-travel debugging overlay (frame scrubber + entity inspector). */
|
|
25
|
-
devtools?: boolean;
|
|
26
|
-
/** Run the simulation in deterministic mode using a seeded RNG. */
|
|
27
|
-
deterministic?: boolean;
|
|
28
|
-
/** Seed for the deterministic RNG (default 0). Only used when deterministic=true. */
|
|
29
|
-
seed?: number;
|
|
30
|
-
/**
|
|
31
|
-
* When true, the game loop starts immediately and sprites swap from color → image as
|
|
32
|
-
* they load in the background. When false (default) the loop is held until every
|
|
33
|
-
* sprite that is part of the initial scene has finished loading, so the first frame
|
|
34
|
-
* shown is fully rendered with real assets.
|
|
35
|
-
*/
|
|
36
|
-
asyncAssets?: boolean;
|
|
37
|
-
/** Custom plugins to register after core systems. Each plugin's systems run after Render. */
|
|
38
|
-
plugins?: Plugin[];
|
|
39
|
-
/**
|
|
40
|
-
* Custom render system constructor. Must implement the System interface and accept
|
|
41
|
-
* `(canvas: HTMLCanvasElement, entityIds: Map<string, EntityId>)`.
|
|
42
|
-
*
|
|
43
|
-
* Defaults to the built-in Canvas2D RenderSystem.
|
|
44
|
-
* Example: `import { WebGLRenderSystem } from '@cubeforge/webgl-renderer'`
|
|
45
|
-
*/
|
|
46
|
-
renderer?: new (canvas: HTMLCanvasElement, entityIds: Map<string, EntityId>) => System;
|
|
47
|
-
style?: CSSProperties;
|
|
48
|
-
className?: string;
|
|
49
|
-
children?: React.ReactNode;
|
|
50
|
-
}
|
|
51
|
-
export declare function Game({ width, height, gravity, debug, devtools, scale, deterministic, seed, asyncAssets, onReady, plugins, renderer: CustomRenderer, style, className, children, }: GameProps): import("react/jsx-runtime").JSX.Element;
|
|
52
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface MovingPlatformProps {
|
|
3
|
-
/** Start position */
|
|
4
|
-
x1: number;
|
|
5
|
-
y1: number;
|
|
6
|
-
/** End position */
|
|
7
|
-
x2: number;
|
|
8
|
-
y2: number;
|
|
9
|
-
width?: number;
|
|
10
|
-
height?: number;
|
|
11
|
-
/** Seconds for a full round trip (default 3) */
|
|
12
|
-
duration?: number;
|
|
13
|
-
color?: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* A static platform that oscillates between (x1,y1) and (x2,y2).
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* <MovingPlatform x1={200} y1={350} x2={450} y2={350} width={120} duration={2.5} />
|
|
20
|
-
*/
|
|
21
|
-
export declare function MovingPlatform({ x1, y1, x2, y2, width, height, duration, color, }: MovingPlatformProps): React.ReactElement;
|
|
22
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface ParallaxLayerProps {
|
|
3
|
-
/** Image URL to use as the background layer */
|
|
4
|
-
src: string;
|
|
5
|
-
/** Scroll speed relative to camera (0 = fixed, 1 = moves with camera, 0.3 = slow parallax). Default 0.5 */
|
|
6
|
-
speedX?: number;
|
|
7
|
-
/** Vertical scroll speed relative to camera. Default 0 */
|
|
8
|
-
speedY?: number;
|
|
9
|
-
/** Tile image horizontally. Default true */
|
|
10
|
-
repeatX?: boolean;
|
|
11
|
-
/** Tile image vertically. Default false */
|
|
12
|
-
repeatY?: boolean;
|
|
13
|
-
/** Render order — use negative values to render behind sprites. Default -10 */
|
|
14
|
-
zIndex?: number;
|
|
15
|
-
/** Manual horizontal offset in pixels. Default 0 */
|
|
16
|
-
offsetX?: number;
|
|
17
|
-
/** Manual vertical offset in pixels. Default 0 */
|
|
18
|
-
offsetY?: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* A background layer that scrolls at a fraction of the camera speed to create depth.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* <ParallaxLayer src="/bg/sky.png" speedX={0.2} repeatX />
|
|
25
|
-
* <ParallaxLayer src="/bg/mountains.png" speedX={0.5} repeatX zIndex={-5} />
|
|
26
|
-
*/
|
|
27
|
-
export declare function ParallaxLayer({ src, speedX, speedY, repeatX, repeatY, zIndex, offsetX, offsetY, }: ParallaxLayerProps): React.ReactElement;
|
|
28
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ParticlePreset } from './particlePresets';
|
|
2
|
-
interface ParticleEmitterProps {
|
|
3
|
-
active?: boolean;
|
|
4
|
-
/** Named preset — values can be overridden by explicit props */
|
|
5
|
-
preset?: ParticlePreset;
|
|
6
|
-
/** Particles per second, default 20 */
|
|
7
|
-
rate?: number;
|
|
8
|
-
/** Initial particle speed (pixels/s), default 80 */
|
|
9
|
-
speed?: number;
|
|
10
|
-
/** Angle spread in radians, default Math.PI */
|
|
11
|
-
spread?: number;
|
|
12
|
-
/** Base emit angle in radians (0=right, -PI/2=up), default -Math.PI/2 */
|
|
13
|
-
angle?: number;
|
|
14
|
-
/** Particle lifetime in seconds, default 0.8 */
|
|
15
|
-
particleLife?: number;
|
|
16
|
-
/** Particle size in pixels, default 4 */
|
|
17
|
-
particleSize?: number;
|
|
18
|
-
/** Particle color, default '#ffffff' */
|
|
19
|
-
color?: string;
|
|
20
|
-
/** Gravity applied to particles (pixels/s²), default 200 */
|
|
21
|
-
gravity?: number;
|
|
22
|
-
/** Maximum live particles, default 100 */
|
|
23
|
-
maxParticles?: number;
|
|
24
|
-
}
|
|
25
|
-
export declare function ParticleEmitter({ active, preset, rate, speed, spread, angle, particleLife, particleSize, color, gravity, maxParticles, }: ParticleEmitterProps): null;
|
|
26
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
interface RigidBodyProps {
|
|
2
|
-
mass?: number;
|
|
3
|
-
gravityScale?: number;
|
|
4
|
-
isStatic?: boolean;
|
|
5
|
-
bounce?: number;
|
|
6
|
-
friction?: number;
|
|
7
|
-
vx?: number;
|
|
8
|
-
vy?: number;
|
|
9
|
-
/** Prevent any horizontal movement — velocity.x is zeroed every frame */
|
|
10
|
-
lockX?: boolean;
|
|
11
|
-
/** Prevent any vertical movement — velocity.y is zeroed every frame (disables gravity) */
|
|
12
|
-
lockY?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare function RigidBody({ mass, gravityScale, isStatic, bounce, friction, vx, vy, lockX, lockY, }: RigidBodyProps): null;
|
|
15
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type ScriptUpdateFn } from '@cubeforge/core';
|
|
2
|
-
import type { ECSWorld, EntityId } from '@cubeforge/core';
|
|
3
|
-
import type { InputManager } from '@cubeforge/input';
|
|
4
|
-
interface ScriptProps {
|
|
5
|
-
/** Called once when the entity is mounted — use to attach extra components */
|
|
6
|
-
init?: (entityId: EntityId, world: ECSWorld) => void;
|
|
7
|
-
/** Called every frame */
|
|
8
|
-
update: ScriptUpdateFn | ((entityId: EntityId, world: ECSWorld, input: InputManager, dt: number) => void);
|
|
9
|
-
}
|
|
10
|
-
export declare function Script({ init, update }: ScriptProps): null;
|
|
11
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { SpriteAtlas } from './spriteAtlas';
|
|
2
|
-
interface SpriteProps {
|
|
3
|
-
width: number;
|
|
4
|
-
height: number;
|
|
5
|
-
color?: string;
|
|
6
|
-
src?: string;
|
|
7
|
-
offsetX?: number;
|
|
8
|
-
offsetY?: number;
|
|
9
|
-
zIndex?: number;
|
|
10
|
-
visible?: boolean;
|
|
11
|
-
flipX?: boolean;
|
|
12
|
-
anchorX?: number;
|
|
13
|
-
anchorY?: number;
|
|
14
|
-
frameIndex?: number;
|
|
15
|
-
frameWidth?: number;
|
|
16
|
-
frameHeight?: number;
|
|
17
|
-
frameColumns?: number;
|
|
18
|
-
atlas?: SpriteAtlas;
|
|
19
|
-
frame?: string;
|
|
20
|
-
}
|
|
21
|
-
export declare function Sprite({ width, height, color, src, offsetX, offsetY, zIndex, visible, flipX, anchorX, anchorY, frameIndex, frameWidth, frameHeight, frameColumns, atlas, frame, }: SpriteProps): null;
|
|
22
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
interface SquashStretchProps {
|
|
2
|
-
/** How much to squash/stretch (default 0.2) */
|
|
3
|
-
intensity?: number;
|
|
4
|
-
/** How fast it returns to 1.0 — lerp speed (default 8) */
|
|
5
|
-
recovery?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare function SquashStretch({ intensity, recovery }: SquashStretchProps): null;
|
|
8
|
-
export {};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface TiledProperty {
|
|
3
|
-
name: string;
|
|
4
|
-
type: string;
|
|
5
|
-
value: string | number | boolean;
|
|
6
|
-
}
|
|
7
|
-
export interface TiledObject {
|
|
8
|
-
id: number;
|
|
9
|
-
name: string;
|
|
10
|
-
type: string;
|
|
11
|
-
x: number;
|
|
12
|
-
y: number;
|
|
13
|
-
width: number;
|
|
14
|
-
height: number;
|
|
15
|
-
properties?: TiledProperty[];
|
|
16
|
-
}
|
|
17
|
-
export interface TiledLayer {
|
|
18
|
-
type: 'tilelayer' | 'objectgroup';
|
|
19
|
-
name: string;
|
|
20
|
-
visible: boolean;
|
|
21
|
-
opacity: number;
|
|
22
|
-
data?: number[];
|
|
23
|
-
objects?: TiledObject[];
|
|
24
|
-
properties?: TiledProperty[];
|
|
25
|
-
}
|
|
26
|
-
interface TilemapProps {
|
|
27
|
-
/** URL to the Tiled JSON file */
|
|
28
|
-
src: string;
|
|
29
|
-
/**
|
|
30
|
-
* Object layer spawner: called for each object in object layers.
|
|
31
|
-
* Return a React element or null.
|
|
32
|
-
*/
|
|
33
|
-
onSpawnObject?: (obj: TiledObject, layer: TiledLayer) => React.ReactNode;
|
|
34
|
-
/**
|
|
35
|
-
* Layer filter: return false to skip rendering/processing a layer.
|
|
36
|
-
* Default: all layers rendered.
|
|
37
|
-
*/
|
|
38
|
-
layerFilter?: (layer: TiledLayer) => boolean;
|
|
39
|
-
/** Z-index for tile sprites (default 0) */
|
|
40
|
-
zIndex?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Name of the layer (or layers with property `collision: true`) that
|
|
43
|
-
* should create invisible solid colliders. Default: "collision".
|
|
44
|
-
*/
|
|
45
|
-
collisionLayer?: string;
|
|
46
|
-
/**
|
|
47
|
-
* Name of the layer (or layers with property `trigger: true`) that
|
|
48
|
-
* should create trigger BoxColliders (no sprite). Default: "triggers".
|
|
49
|
-
*/
|
|
50
|
-
triggerLayer?: string;
|
|
51
|
-
/**
|
|
52
|
-
* Called for every tile that has custom properties defined in the tileset.
|
|
53
|
-
* Receives the global tile ID, the property map, and the tile's world position.
|
|
54
|
-
*/
|
|
55
|
-
onTileProperty?: (tileId: number, properties: Record<string, unknown>, x: number, y: number) => void;
|
|
56
|
-
}
|
|
57
|
-
export declare function Tilemap({ src, onSpawnObject, layerFilter, zIndex, collisionLayer, triggerLayer: triggerLayerName, onTileProperty, }: TilemapProps): React.ReactElement | null;
|
|
58
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
interface WorldProps {
|
|
3
|
-
/** Gravitational acceleration in pixels/s² (default inherited from Game) */
|
|
4
|
-
gravity?: number;
|
|
5
|
-
/** Canvas background color */
|
|
6
|
-
background?: string;
|
|
7
|
-
children?: ReactNode;
|
|
8
|
-
}
|
|
9
|
-
export declare function World({ gravity, background, children }: WorldProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type ParticlePreset = 'explosion' | 'spark' | 'smoke' | 'coinPickup' | 'jumpDust';
|
|
2
|
-
export interface ParticleEmitterConfig {
|
|
3
|
-
rate?: number;
|
|
4
|
-
speed?: number;
|
|
5
|
-
spread?: number;
|
|
6
|
-
angle?: number;
|
|
7
|
-
particleLife?: number;
|
|
8
|
-
particleSize?: number;
|
|
9
|
-
color?: string;
|
|
10
|
-
gravity?: number;
|
|
11
|
-
maxParticles?: number;
|
|
12
|
-
}
|
|
13
|
-
export declare const PARTICLE_PRESETS: Record<ParticlePreset, ParticleEmitterConfig>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Maps frame names to frameIndex numbers */
|
|
2
|
-
export type SpriteAtlas = Record<string, number>;
|
|
3
|
-
/**
|
|
4
|
-
* Helper to build an atlas from a grid spritesheet.
|
|
5
|
-
* columns = number of frames per row.
|
|
6
|
-
* names = frame names in row-major order.
|
|
7
|
-
*/
|
|
8
|
-
export declare function createAtlas(names: string[], _columns: number): SpriteAtlas;
|
package/dist/context.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ECSWorld, EventBus, AssetManager, EntityId } from '@cubeforge/core';
|
|
2
|
-
import type { InputManager } from '@cubeforge/input';
|
|
3
|
-
import type { Canvas2DRenderer, RenderSystem } from '@cubeforge/renderer';
|
|
4
|
-
import type { PhysicsSystem } from '@cubeforge/physics';
|
|
5
|
-
import type { GameLoop } from '@cubeforge/core';
|
|
6
|
-
export interface EngineState {
|
|
7
|
-
ecs: ECSWorld;
|
|
8
|
-
input: InputManager;
|
|
9
|
-
/** Canvas2D renderer. Undefined when a custom WebGL renderer is used via the `renderer` Game prop. */
|
|
10
|
-
renderer?: Canvas2DRenderer;
|
|
11
|
-
/** The active render system. Undefined when a custom renderer is used. */
|
|
12
|
-
renderSystem?: RenderSystem;
|
|
13
|
-
physics: PhysicsSystem;
|
|
14
|
-
events: EventBus;
|
|
15
|
-
assets: AssetManager;
|
|
16
|
-
loop: GameLoop;
|
|
17
|
-
canvas: HTMLCanvasElement;
|
|
18
|
-
/** Maps string entity IDs (e.g. "player") to numeric ECS EntityIds */
|
|
19
|
-
entityIds: Map<string, EntityId>;
|
|
20
|
-
}
|
|
21
|
-
export declare const EngineContext: import("react").Context<EngineState | null>;
|
|
22
|
-
export declare const EntityContext: import("react").Context<number | null>;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export interface CameraControls {
|
|
2
|
-
/**
|
|
3
|
-
* Trigger a screen-shake effect.
|
|
4
|
-
* @param intensity - Maximum pixel displacement per frame.
|
|
5
|
-
* @param duration - How long the shake lasts in seconds.
|
|
6
|
-
*/
|
|
7
|
-
shake(intensity: number, duration: number): void;
|
|
8
|
-
/**
|
|
9
|
-
* Set the world-space offset applied to the camera's follow target.
|
|
10
|
-
* Useful for look-ahead: `setFollowOffset(facing * 80, 0)`.
|
|
11
|
-
*/
|
|
12
|
-
setFollowOffset(x: number, y: number): void;
|
|
13
|
-
/**
|
|
14
|
-
* Instantly move the camera center to a world-space position.
|
|
15
|
-
* Bypasses smoothing — useful for instant scene cuts.
|
|
16
|
-
*/
|
|
17
|
-
setPosition(x: number, y: number): void;
|
|
18
|
-
/**
|
|
19
|
-
* Programmatically set the camera zoom level.
|
|
20
|
-
*/
|
|
21
|
-
setZoom(zoom: number): void;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Returns controls for the active Camera2D in the scene.
|
|
25
|
-
* Must be used inside `<Game>`.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```tsx
|
|
29
|
-
* function HUD() {
|
|
30
|
-
* const camera = useCamera()
|
|
31
|
-
* return (
|
|
32
|
-
* <button onClick={() => camera.shake(8, 0.4)}>Shake!</button>
|
|
33
|
-
* )
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function useCamera(): CameraControls;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { EntityId } from '@cubeforge/core';
|
|
2
|
-
interface ContactOpts {
|
|
3
|
-
/** Only fire if the other entity has this tag */
|
|
4
|
-
tag?: string;
|
|
5
|
-
/** Only fire if the other entity's BoxCollider is on this layer */
|
|
6
|
-
layer?: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Fires once when another entity's collider first overlaps this entity's trigger.
|
|
10
|
-
* Must be used inside an `<Entity>`.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* function CoinPickup() {
|
|
14
|
-
* useTriggerEnter((other) => collectCoin(), { tag: 'player' })
|
|
15
|
-
* return null
|
|
16
|
-
* }
|
|
17
|
-
*/
|
|
18
|
-
export declare function useTriggerEnter(handler: (other: EntityId) => void, opts?: ContactOpts): void;
|
|
19
|
-
/**
|
|
20
|
-
* Fires once when an overlapping entity's collider leaves this entity's trigger.
|
|
21
|
-
* Must be used inside an `<Entity>`.
|
|
22
|
-
*/
|
|
23
|
-
export declare function useTriggerExit(handler: (other: EntityId) => void, opts?: ContactOpts): void;
|
|
24
|
-
/**
|
|
25
|
-
* Fires once on the first frame two solid dynamic bodies touch.
|
|
26
|
-
* Must be used inside an `<Entity>`.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* function Enemy() {
|
|
30
|
-
* useCollisionEnter((other) => takeDamage(), { tag: 'player' })
|
|
31
|
-
* return null
|
|
32
|
-
* }
|
|
33
|
-
*/
|
|
34
|
-
export declare function useCollisionEnter(handler: (other: EntityId) => void, opts?: ContactOpts): void;
|
|
35
|
-
/**
|
|
36
|
-
* Fires once when two solid dynamic bodies separate.
|
|
37
|
-
* Must be used inside an `<Entity>`.
|
|
38
|
-
*/
|
|
39
|
-
export declare function useCollisionExit(handler: (other: EntityId) => void, opts?: ContactOpts): void;
|
|
40
|
-
/**
|
|
41
|
-
* Fires once when another entity's CircleCollider first overlaps this entity's CircleCollider.
|
|
42
|
-
* Also fires when a CircleCollider overlaps a BoxCollider.
|
|
43
|
-
* Must be used inside an `<Entity>`.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* function Asteroid() {
|
|
47
|
-
* useCircleEnter((other) => onHit(other), { tag: 'bullet' })
|
|
48
|
-
* return null
|
|
49
|
-
* }
|
|
50
|
-
*/
|
|
51
|
-
export declare function useCircleEnter(handler: (other: EntityId) => void, opts?: ContactOpts): void;
|
|
52
|
-
/**
|
|
53
|
-
* Fires once when two CircleCollider entities stop overlapping.
|
|
54
|
-
* Must be used inside an `<Entity>`.
|
|
55
|
-
*/
|
|
56
|
-
export declare function useCircleExit(handler: (other: EntityId) => void, opts?: ContactOpts): void;
|
|
57
|
-
export {};
|
package/dist/hooks/useGame.d.ts
DELETED
package/dist/hooks/useInput.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ActionBindings } from '@cubeforge/input';
|
|
2
|
-
export interface BoundInputMap {
|
|
3
|
-
/** True every frame any bound key is held. */
|
|
4
|
-
isActionDown(action: string): boolean;
|
|
5
|
-
/** True only on the first frame any bound key was pressed. */
|
|
6
|
-
isActionPressed(action: string): boolean;
|
|
7
|
-
/** True only on the frame any bound key was released. */
|
|
8
|
-
isActionReleased(action: string): boolean;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* React hook that returns a pre-bound action map for use inside `<Game>`.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```tsx
|
|
15
|
-
* function MyScript() {
|
|
16
|
-
* const actions = useInputMap({
|
|
17
|
-
* left: ['ArrowLeft', 'KeyA'],
|
|
18
|
-
* right: ['ArrowRight', 'KeyD'],
|
|
19
|
-
* jump: ['Space', 'ArrowUp', 'KeyW'],
|
|
20
|
-
* })
|
|
21
|
-
* // use actions.isActionDown('left') in a Script update or game loop callback
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export declare function useInputMap(bindings: ActionBindings): BoundInputMap;
|