@guinetik/gcanvas 1.0.0 → 1.0.2
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/demos/coordinates.html +698 -0
- package/demos/cube3d.html +23 -0
- package/demos/demos.css +17 -3
- package/demos/dino.html +42 -0
- package/demos/fluid-simple.html +22 -0
- package/demos/fluid.html +37 -0
- package/demos/gameobjects.html +626 -0
- package/demos/index.html +19 -7
- package/demos/js/blob.js +18 -5
- package/demos/js/coordinates.js +840 -0
- package/demos/js/cube3d.js +789 -0
- package/demos/js/dino.js +1420 -0
- package/demos/js/fluid-simple.js +253 -0
- package/demos/js/fluid.js +527 -0
- package/demos/js/gameobjects.js +176 -0
- package/demos/js/plane3d.js +256 -0
- package/demos/js/platformer.js +1579 -0
- package/demos/js/sphere3d.js +229 -0
- package/demos/js/sprite.js +473 -0
- package/demos/js/tde/accretiondisk.js +65 -12
- package/demos/js/tde/blackholescene.js +2 -2
- package/demos/js/tde/config.js +2 -2
- package/demos/js/tde/index.js +152 -27
- package/demos/js/tde/lensedstarfield.js +32 -25
- package/demos/js/tde/tdestar.js +78 -98
- package/demos/js/tde/tidalstream.js +24 -8
- package/demos/plane3d.html +24 -0
- package/demos/platformer.html +43 -0
- package/demos/sphere3d.html +24 -0
- package/demos/sprite.html +18 -0
- package/docs/README.md +230 -222
- package/docs/api/FluidSystem.md +173 -0
- package/docs/concepts/architecture-overview.md +204 -204
- package/docs/concepts/coordinate-system.md +384 -0
- package/docs/concepts/rendering-pipeline.md +279 -279
- package/docs/concepts/shapes-vs-gameobjects.md +187 -0
- package/docs/concepts/two-layer-architecture.md +229 -229
- package/docs/fluid-dynamics.md +99 -0
- package/docs/getting-started/first-game.md +354 -354
- package/docs/getting-started/installation.md +175 -157
- package/docs/modules/collision/README.md +2 -2
- package/docs/modules/fluent/README.md +6 -6
- package/docs/modules/game/README.md +303 -303
- package/docs/modules/isometric-camera.md +2 -2
- package/docs/modules/isometric.md +1 -1
- package/docs/modules/painter/README.md +328 -328
- package/docs/modules/particle/README.md +3 -3
- package/docs/modules/shapes/README.md +221 -221
- package/docs/modules/shapes/base/euclidian.md +123 -123
- package/docs/modules/shapes/base/shape.md +262 -262
- package/docs/modules/shapes/base/transformable.md +243 -243
- package/docs/modules/state/README.md +2 -2
- package/docs/modules/util/README.md +1 -1
- package/docs/modules/util/camera3d.md +3 -3
- package/docs/modules/util/scene3d.md +1 -1
- package/package.json +3 -1
- package/readme.md +19 -5
- package/src/collision/collision.js +75 -0
- package/src/game/game.js +11 -5
- package/src/game/index.js +2 -1
- package/src/game/objects/index.js +3 -0
- package/src/game/objects/platformer-scene.js +411 -0
- package/src/game/objects/scene.js +14 -0
- package/src/game/objects/sprite.js +529 -0
- package/src/game/pipeline.js +20 -16
- package/src/game/systems/FluidSystem.js +835 -0
- package/src/game/systems/index.js +11 -0
- package/src/game/ui/button.js +39 -18
- package/src/game/ui/cursor.js +14 -0
- package/src/game/ui/fps.js +12 -4
- package/src/game/ui/index.js +2 -0
- package/src/game/ui/stepper.js +549 -0
- package/src/game/ui/theme.js +123 -0
- package/src/game/ui/togglebutton.js +9 -3
- package/src/game/ui/tooltip.js +11 -4
- package/src/io/input.js +75 -45
- package/src/io/mouse.js +44 -19
- package/src/io/touch.js +35 -12
- package/src/math/fluid.js +507 -0
- package/src/math/index.js +2 -0
- package/src/mixins/anchor.js +17 -7
- package/src/motion/tweenetik.js +16 -0
- package/src/shapes/cube3d.js +599 -0
- package/src/shapes/index.js +3 -0
- package/src/shapes/plane3d.js +687 -0
- package/src/shapes/sphere3d.js +75 -6
- package/src/util/camera2d.js +315 -0
- package/src/util/camera3d.js +218 -12
- package/src/util/index.js +1 -0
- package/src/webgl/shaders/plane-shaders.js +332 -0
- package/src/webgl/shaders/sphere-shaders.js +4 -2
- package/types/fluent.d.ts +361 -0
- package/types/game.d.ts +303 -0
- package/types/index.d.ts +144 -5
- package/types/math.d.ts +361 -0
- package/types/motion.d.ts +271 -0
- package/types/particle.d.ts +373 -0
- package/types/shapes.d.ts +107 -9
- package/types/util.d.ts +353 -0
- package/types/webgl.d.ts +109 -0
- package/disk_example.png +0 -0
- package/tde.png +0 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/// <reference lib="es2015" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* GCanvas Fluent API Module
|
|
5
|
+
* Declarative, chainable API for rapid game and creative coding development.
|
|
6
|
+
* @module fluent
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Game, Scene, GameObject, GameObjectOptions, SceneOptions } from './game';
|
|
10
|
+
import { Shape } from './shapes';
|
|
11
|
+
import { Easing, Motion, Tweenetik } from './motion';
|
|
12
|
+
import { Keys, Mouse } from './io';
|
|
13
|
+
|
|
14
|
+
// ==========================================================================
|
|
15
|
+
// Main Entry Points
|
|
16
|
+
// ==========================================================================
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Main entry point for the fluent API.
|
|
20
|
+
* Creates a FluentGame instance with automatic canvas setup.
|
|
21
|
+
*
|
|
22
|
+
* @param options - Game configuration
|
|
23
|
+
* @returns FluentGame builder instance
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* gcanvas({ bg: 'black' })
|
|
27
|
+
* .scene('game')
|
|
28
|
+
* .go({ x: 400, y: 300, name: 'player' })
|
|
29
|
+
* .circle({ radius: 30, fill: 'lime' })
|
|
30
|
+
* .start();
|
|
31
|
+
*/
|
|
32
|
+
export function gcanvas(options?: FluentGameOptions): FluentGame;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Ultra-simple sketch mode for quick creative coding prototypes.
|
|
36
|
+
*
|
|
37
|
+
* @param w - Canvas width (default: 800)
|
|
38
|
+
* @param h - Canvas height (default: 600)
|
|
39
|
+
* @param bg - Background color (default: 'black')
|
|
40
|
+
* @returns SketchAPI builder instance
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* sketch(800, 600, 'black')
|
|
44
|
+
* .circle(400, 300, 50, 'lime')
|
|
45
|
+
* .update((dt, ctx) => {
|
|
46
|
+
* ctx.shapes[0].x += Math.sin(ctx.time) * 2;
|
|
47
|
+
* })
|
|
48
|
+
* .start();
|
|
49
|
+
*/
|
|
50
|
+
export function sketch(w?: number, h?: number, bg?: string): SketchAPI;
|
|
51
|
+
|
|
52
|
+
// ==========================================================================
|
|
53
|
+
// FluentGame Options
|
|
54
|
+
// ==========================================================================
|
|
55
|
+
|
|
56
|
+
/** Options for FluentGame constructor */
|
|
57
|
+
export interface FluentGameOptions {
|
|
58
|
+
/** Canvas element to use (auto-creates if not provided) */
|
|
59
|
+
canvas?: HTMLCanvasElement;
|
|
60
|
+
/** Canvas width when auto-creating (default: 800) */
|
|
61
|
+
width?: number;
|
|
62
|
+
/** Canvas height when auto-creating (default: 600) */
|
|
63
|
+
height?: number;
|
|
64
|
+
/** Background color */
|
|
65
|
+
bg?: string;
|
|
66
|
+
/** Enable fluid/responsive sizing (default: true for auto-created canvas) */
|
|
67
|
+
fluid?: boolean;
|
|
68
|
+
/** Container for auto-created canvas (default: document.body) */
|
|
69
|
+
container?: HTMLElement;
|
|
70
|
+
/** Target FPS (default: 60) */
|
|
71
|
+
fps?: number;
|
|
72
|
+
/** Pixel ratio for HiDPI displays */
|
|
73
|
+
pixelRatio?: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ==========================================================================
|
|
77
|
+
// FluentGame Class
|
|
78
|
+
// ==========================================================================
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Root builder class for the fluent API.
|
|
82
|
+
* Wraps the Game class with a declarative, chainable interface.
|
|
83
|
+
*/
|
|
84
|
+
export class FluentGame {
|
|
85
|
+
constructor(options?: FluentGameOptions);
|
|
86
|
+
|
|
87
|
+
// Scene Management
|
|
88
|
+
/**
|
|
89
|
+
* Create or switch to a scene.
|
|
90
|
+
* @param name - Scene identifier
|
|
91
|
+
* @param options - Scene options
|
|
92
|
+
*/
|
|
93
|
+
scene(name: string, options?: FluentSceneOptions): FluentScene;
|
|
94
|
+
/**
|
|
95
|
+
* Create scene with custom Scene class.
|
|
96
|
+
* @param name - Scene identifier
|
|
97
|
+
* @param sceneClass - Custom Scene class
|
|
98
|
+
* @param options - Scene options
|
|
99
|
+
*/
|
|
100
|
+
scene(name: string, sceneClass: new (...args: any[]) => Scene, options?: FluentSceneOptions): FluentScene;
|
|
101
|
+
/**
|
|
102
|
+
* Create scene with custom Scene class (name derived from class).
|
|
103
|
+
* @param sceneClass - Custom Scene class
|
|
104
|
+
* @param options - Scene options
|
|
105
|
+
*/
|
|
106
|
+
scene(sceneClass: new (...args: any[]) => Scene, options?: FluentSceneOptions): FluentScene;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Switch context to an existing scene (does not create).
|
|
110
|
+
* @param name - Scene name
|
|
111
|
+
*/
|
|
112
|
+
inScene(name: string): FluentScene;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Shortcut: create GameObject in current/default scene.
|
|
116
|
+
* @param options - GameObject options
|
|
117
|
+
*/
|
|
118
|
+
go(options?: GameObjectOptions): FluentGO;
|
|
119
|
+
/**
|
|
120
|
+
* Create GameObject with custom class.
|
|
121
|
+
* @param goClass - Custom GameObject class
|
|
122
|
+
* @param options - GameObject options
|
|
123
|
+
*/
|
|
124
|
+
go(goClass: new (...args: any[]) => GameObject, options?: GameObjectOptions): FluentGO;
|
|
125
|
+
|
|
126
|
+
// Scene Visibility
|
|
127
|
+
/** Show a scene by name */
|
|
128
|
+
showScene(name: string): FluentGame;
|
|
129
|
+
/** Hide a scene by name */
|
|
130
|
+
hideScene(name: string): FluentGame;
|
|
131
|
+
/** Transition between scenes */
|
|
132
|
+
transition(from: string, to: string, options?: TransitionOptions): FluentGame;
|
|
133
|
+
|
|
134
|
+
// State Management
|
|
135
|
+
/** Set initial state */
|
|
136
|
+
state(initialState: Record<string, any>): FluentGame;
|
|
137
|
+
/** Get a state value */
|
|
138
|
+
getState<T = any>(key: string): T;
|
|
139
|
+
/** Set a state value */
|
|
140
|
+
setState(key: string, value: any): FluentGame;
|
|
141
|
+
|
|
142
|
+
// Events & Lifecycle
|
|
143
|
+
/**
|
|
144
|
+
* Register event handler.
|
|
145
|
+
* @param event - Event name (update, keydown:escape, click, etc.)
|
|
146
|
+
* @param handler - Handler function
|
|
147
|
+
*/
|
|
148
|
+
on(event: string, handler: (ctx: FluentContext, e?: any) => void): FluentGame;
|
|
149
|
+
on(event: 'update', handler: (dt: number, ctx: FluentContext) => void): FluentGame;
|
|
150
|
+
|
|
151
|
+
// Plugins
|
|
152
|
+
/** Use a plugin or scene builder function */
|
|
153
|
+
use(plugin: (game: FluentGame) => void): FluentGame;
|
|
154
|
+
|
|
155
|
+
// Lifecycle
|
|
156
|
+
/** Start the game loop */
|
|
157
|
+
start(): FluentGame;
|
|
158
|
+
/** Stop the game loop */
|
|
159
|
+
stop(): FluentGame;
|
|
160
|
+
/** Restart the game */
|
|
161
|
+
restart(): FluentGame;
|
|
162
|
+
|
|
163
|
+
// Accessors
|
|
164
|
+
/** Underlying Game instance */
|
|
165
|
+
readonly game: Game;
|
|
166
|
+
/** Named object references */
|
|
167
|
+
readonly refs: Record<string, GameObject>;
|
|
168
|
+
/** All scenes */
|
|
169
|
+
readonly scenes: Map<string, Scene>;
|
|
170
|
+
/** Canvas element */
|
|
171
|
+
readonly canvas: HTMLCanvasElement;
|
|
172
|
+
/** Canvas width */
|
|
173
|
+
readonly width: number;
|
|
174
|
+
/** Canvas height */
|
|
175
|
+
readonly height: number;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ==========================================================================
|
|
179
|
+
// FluentScene Class
|
|
180
|
+
// ==========================================================================
|
|
181
|
+
|
|
182
|
+
/** Options for fluent scene creation */
|
|
183
|
+
export interface FluentSceneOptions extends SceneOptions {
|
|
184
|
+
/** Scene z-index (default: 0) */
|
|
185
|
+
zIndex?: number;
|
|
186
|
+
/** Whether scene is visible (default: true) */
|
|
187
|
+
active?: boolean;
|
|
188
|
+
/** Scene enter callback */
|
|
189
|
+
onEnter?: (ctx: FluentContext) => void;
|
|
190
|
+
/** Scene exit callback */
|
|
191
|
+
onExit?: (ctx: FluentContext) => void;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Transition options */
|
|
195
|
+
export interface TransitionOptions {
|
|
196
|
+
/** Fade duration in seconds */
|
|
197
|
+
fade?: number;
|
|
198
|
+
/** Completion callback */
|
|
199
|
+
onComplete?: () => void;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Scene builder for the fluent API.
|
|
204
|
+
*/
|
|
205
|
+
export class FluentScene {
|
|
206
|
+
/**
|
|
207
|
+
* Create a GameObject in this scene.
|
|
208
|
+
* @param options - GameObject options
|
|
209
|
+
*/
|
|
210
|
+
go(options?: GameObjectOptions): FluentGO;
|
|
211
|
+
/**
|
|
212
|
+
* Create GameObject with custom class.
|
|
213
|
+
* @param goClass - Custom GameObject class
|
|
214
|
+
* @param options - GameObject options
|
|
215
|
+
*/
|
|
216
|
+
go(goClass: new (...args: any[]) => GameObject, options?: GameObjectOptions): FluentGO;
|
|
217
|
+
|
|
218
|
+
/** Return to FluentGame context */
|
|
219
|
+
end(): FluentGame;
|
|
220
|
+
|
|
221
|
+
/** Access the underlying scene */
|
|
222
|
+
readonly sceneInstance: Scene;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// ==========================================================================
|
|
226
|
+
// FluentGO Class
|
|
227
|
+
// ==========================================================================
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* GameObject builder for the fluent API.
|
|
231
|
+
* Provides chainable methods for adding shapes and behaviors.
|
|
232
|
+
*/
|
|
233
|
+
export class FluentGO {
|
|
234
|
+
// Shape methods
|
|
235
|
+
circle(options?: { radius?: number; fill?: string; stroke?: string }): FluentGO;
|
|
236
|
+
rect(options?: { width?: number; height?: number; fill?: string; stroke?: string }): FluentGO;
|
|
237
|
+
square(options?: { size?: number; fill?: string; stroke?: string }): FluentGO;
|
|
238
|
+
star(options?: { points?: number; radius?: number; innerRadius?: number; fill?: string }): FluentGO;
|
|
239
|
+
triangle(options?: { size?: number; fill?: string }): FluentGO;
|
|
240
|
+
hexagon(options?: { radius?: number; fill?: string }): FluentGO;
|
|
241
|
+
line(options?: { x2?: number; y2?: number; stroke?: string; lineWidth?: number }): FluentGO;
|
|
242
|
+
ring(options?: { innerRadius?: number; outerRadius?: number; fill?: string }): FluentGO;
|
|
243
|
+
text(content: string, options?: { fill?: string; font?: string }): FluentGO;
|
|
244
|
+
|
|
245
|
+
// Motion methods (apply behaviors)
|
|
246
|
+
pulse(options?: { min?: number; max?: number; duration?: number }): FluentGO;
|
|
247
|
+
orbit(options?: { radius?: number; speed?: number; centerX?: number; centerY?: number }): FluentGO;
|
|
248
|
+
oscillate(options?: { axis?: 'x' | 'y'; amplitude?: number; frequency?: number }): FluentGO;
|
|
249
|
+
bounce(options?: { height?: number; duration?: number }): FluentGO;
|
|
250
|
+
shake(options?: { intensity?: number; duration?: number }): FluentGO;
|
|
251
|
+
float(options?: { amplitude?: number; frequency?: number }): FluentGO;
|
|
252
|
+
spin(options?: { speed?: number }): FluentGO;
|
|
253
|
+
|
|
254
|
+
/** Return to FluentScene context */
|
|
255
|
+
end(): FluentScene;
|
|
256
|
+
|
|
257
|
+
/** Access the underlying GameObject */
|
|
258
|
+
readonly goInstance: GameObject;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// ==========================================================================
|
|
262
|
+
// FluentLayer Class
|
|
263
|
+
// ==========================================================================
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Layer builder for organizing GameObjects at different z-levels.
|
|
267
|
+
*/
|
|
268
|
+
export class FluentLayer {
|
|
269
|
+
/** Add a GameObject to this layer */
|
|
270
|
+
go(options?: GameObjectOptions): FluentGO;
|
|
271
|
+
/** Return to parent context */
|
|
272
|
+
end(): FluentScene;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// ==========================================================================
|
|
276
|
+
// Sketch API
|
|
277
|
+
// ==========================================================================
|
|
278
|
+
|
|
279
|
+
/** Context passed to sketch update function */
|
|
280
|
+
export interface SketchContext {
|
|
281
|
+
/** All created GameObjects */
|
|
282
|
+
shapes: GameObject[];
|
|
283
|
+
/** Elapsed time in seconds */
|
|
284
|
+
time: number;
|
|
285
|
+
/** Current frame number */
|
|
286
|
+
frame: number;
|
|
287
|
+
/** Canvas width */
|
|
288
|
+
width: number;
|
|
289
|
+
/** Canvas height */
|
|
290
|
+
height: number;
|
|
291
|
+
/** Mouse position */
|
|
292
|
+
mouse: { x: number; y: number };
|
|
293
|
+
/** Named object references */
|
|
294
|
+
refs: Record<string, GameObject>;
|
|
295
|
+
/** Underlying Game instance */
|
|
296
|
+
game: Game;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Ultra-simple sketch API for quick prototypes.
|
|
301
|
+
*/
|
|
302
|
+
export interface SketchAPI {
|
|
303
|
+
// Shapes
|
|
304
|
+
circle(x: number, y: number, r: number, fill?: string): SketchAPI;
|
|
305
|
+
rect(x: number, y: number, w: number, h: number, fill?: string): SketchAPI;
|
|
306
|
+
square(x: number, y: number, size: number, fill?: string): SketchAPI;
|
|
307
|
+
star(x: number, y: number, points: number, r: number, fill?: string): SketchAPI;
|
|
308
|
+
triangle(x: number, y: number, size: number, fill?: string): SketchAPI;
|
|
309
|
+
hexagon(x: number, y: number, r: number, fill?: string): SketchAPI;
|
|
310
|
+
line(x1: number, y1: number, x2: number, y2: number, stroke?: string, lineWidth?: number): SketchAPI;
|
|
311
|
+
ring(x: number, y: number, innerRadius: number, outerRadius: number, fill?: string): SketchAPI;
|
|
312
|
+
text(content: string, x: number, y: number, opts?: { fill?: string; font?: string }): SketchAPI;
|
|
313
|
+
|
|
314
|
+
// Bulk creation
|
|
315
|
+
grid(cols: number, rows: number, spacing: number, shapeFn: (api: SketchAPI, x: number, y: number, col: number, row: number) => void): SketchAPI;
|
|
316
|
+
repeat(count: number, shapeFn: (api: SketchAPI, index: number, total: number) => void): SketchAPI;
|
|
317
|
+
radial(cx: number, cy: number, radius: number, count: number, shapeFn: (api: SketchAPI, x: number, y: number, angle: number, index: number) => void): SketchAPI;
|
|
318
|
+
|
|
319
|
+
// Lifecycle
|
|
320
|
+
setup(fn: (api: SketchAPI) => void): SketchAPI;
|
|
321
|
+
update(fn: (dt: number, ctx: SketchContext) => void): SketchAPI;
|
|
322
|
+
start(): FluentGame;
|
|
323
|
+
|
|
324
|
+
// Accessors
|
|
325
|
+
readonly width: number;
|
|
326
|
+
readonly height: number;
|
|
327
|
+
readonly game: FluentGame | null;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// ==========================================================================
|
|
331
|
+
// Fluent Context
|
|
332
|
+
// ==========================================================================
|
|
333
|
+
|
|
334
|
+
/** Context object passed to event handlers */
|
|
335
|
+
export interface FluentContext {
|
|
336
|
+
/** Named object references */
|
|
337
|
+
refs: Record<string, GameObject>;
|
|
338
|
+
/** Game state */
|
|
339
|
+
state: Record<string, any>;
|
|
340
|
+
/** All scenes by name */
|
|
341
|
+
scenes: Record<string, Scene>;
|
|
342
|
+
/** Underlying Game instance */
|
|
343
|
+
game: Game;
|
|
344
|
+
/** Canvas width */
|
|
345
|
+
width: number;
|
|
346
|
+
/** Canvas height */
|
|
347
|
+
height: number;
|
|
348
|
+
/** Show a scene */
|
|
349
|
+
showScene: (name: string) => void;
|
|
350
|
+
/** Hide a scene */
|
|
351
|
+
hideScene: (name: string) => void;
|
|
352
|
+
/** Transition between scenes */
|
|
353
|
+
transition: (from: string, to: string, opts?: TransitionOptions) => void;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// ==========================================================================
|
|
357
|
+
// Re-exports for convenience
|
|
358
|
+
// ==========================================================================
|
|
359
|
+
|
|
360
|
+
export { Motion, Easing, Tweenetik, Keys, Mouse };
|
|
361
|
+
|
package/types/game.d.ts
CHANGED
|
@@ -495,3 +495,306 @@ export class Cursor extends GameObject {
|
|
|
495
495
|
export class FPSCounter extends GameObject {
|
|
496
496
|
constructor(game: Game, options?: GameObjectOptions);
|
|
497
497
|
}
|
|
498
|
+
|
|
499
|
+
// ==========================================================================
|
|
500
|
+
// Advanced UI Components
|
|
501
|
+
// ==========================================================================
|
|
502
|
+
|
|
503
|
+
/** Options for Tooltip */
|
|
504
|
+
export interface TooltipOptions extends GameObjectOptions {
|
|
505
|
+
/** Tooltip text */
|
|
506
|
+
text?: string;
|
|
507
|
+
/** Background color */
|
|
508
|
+
backgroundColor?: string;
|
|
509
|
+
/** Text color */
|
|
510
|
+
textColor?: string;
|
|
511
|
+
/** CSS font string */
|
|
512
|
+
font?: string;
|
|
513
|
+
/** Padding around text */
|
|
514
|
+
padding?: number;
|
|
515
|
+
/** Corner radius */
|
|
516
|
+
cornerRadius?: number;
|
|
517
|
+
/** Show delay in milliseconds */
|
|
518
|
+
delay?: number;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Tooltip component that shows on hover.
|
|
523
|
+
*/
|
|
524
|
+
export class Tooltip extends GameObject {
|
|
525
|
+
/** Tooltip text */
|
|
526
|
+
text: string;
|
|
527
|
+
/** Whether tooltip is visible */
|
|
528
|
+
isVisible: boolean;
|
|
529
|
+
|
|
530
|
+
constructor(game: Game, options?: TooltipOptions);
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Show tooltip at position.
|
|
534
|
+
* @param x - X position
|
|
535
|
+
* @param y - Y position
|
|
536
|
+
*/
|
|
537
|
+
show(x: number, y: number): void;
|
|
538
|
+
|
|
539
|
+
/** Hide tooltip */
|
|
540
|
+
hide(): void;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/** Options for Stepper */
|
|
544
|
+
export interface StepperOptions extends GameObjectOptions {
|
|
545
|
+
/** Minimum value */
|
|
546
|
+
min?: number;
|
|
547
|
+
/** Maximum value */
|
|
548
|
+
max?: number;
|
|
549
|
+
/** Current value */
|
|
550
|
+
value?: number;
|
|
551
|
+
/** Step increment */
|
|
552
|
+
step?: number;
|
|
553
|
+
/** Label text */
|
|
554
|
+
label?: string;
|
|
555
|
+
/** CSS font string */
|
|
556
|
+
font?: string;
|
|
557
|
+
/** Width of the stepper */
|
|
558
|
+
width?: number;
|
|
559
|
+
/** Height of the stepper */
|
|
560
|
+
height?: number;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Numeric stepper component with +/- buttons.
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* const stepper = new Stepper(game, {
|
|
568
|
+
* x: 100, y: 100,
|
|
569
|
+
* min: 0, max: 100,
|
|
570
|
+
* value: 50,
|
|
571
|
+
* step: 5,
|
|
572
|
+
* label: 'Speed'
|
|
573
|
+
* });
|
|
574
|
+
* stepper.on('change', (value) => console.log('New value:', value));
|
|
575
|
+
*/
|
|
576
|
+
export class Stepper extends GameObject {
|
|
577
|
+
/** Current value */
|
|
578
|
+
value: number;
|
|
579
|
+
/** Minimum value */
|
|
580
|
+
min: number;
|
|
581
|
+
/** Maximum value */
|
|
582
|
+
max: number;
|
|
583
|
+
/** Step increment */
|
|
584
|
+
step: number;
|
|
585
|
+
|
|
586
|
+
constructor(game: Game, options?: StepperOptions);
|
|
587
|
+
|
|
588
|
+
/** Increment value by step */
|
|
589
|
+
increment(): void;
|
|
590
|
+
/** Decrement value by step */
|
|
591
|
+
decrement(): void;
|
|
592
|
+
/** Set value directly */
|
|
593
|
+
setValue(value: number): void;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* UI theme constants for consistent styling.
|
|
598
|
+
* Terminal × Vercel aesthetic.
|
|
599
|
+
*/
|
|
600
|
+
export namespace UI_THEME {
|
|
601
|
+
/** Primary accent color (terminal green) */
|
|
602
|
+
const PRIMARY: string;
|
|
603
|
+
/** Background color (dark) */
|
|
604
|
+
const BACKGROUND: string;
|
|
605
|
+
/** Surface color (slightly lighter) */
|
|
606
|
+
const SURFACE: string;
|
|
607
|
+
/** Text color */
|
|
608
|
+
const TEXT: string;
|
|
609
|
+
/** Muted text color */
|
|
610
|
+
const TEXT_MUTED: string;
|
|
611
|
+
/** Border color */
|
|
612
|
+
const BORDER: string;
|
|
613
|
+
/** Success color */
|
|
614
|
+
const SUCCESS: string;
|
|
615
|
+
/** Warning color */
|
|
616
|
+
const WARNING: string;
|
|
617
|
+
/** Error color */
|
|
618
|
+
const ERROR: string;
|
|
619
|
+
/** Font family */
|
|
620
|
+
const FONT: string;
|
|
621
|
+
/** Default corner radius */
|
|
622
|
+
const RADIUS: number;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// ==========================================================================
|
|
626
|
+
// Scene3D
|
|
627
|
+
// ==========================================================================
|
|
628
|
+
|
|
629
|
+
/** Options for Scene3D */
|
|
630
|
+
export interface Scene3DOptions extends SceneOptions {
|
|
631
|
+
/** Camera3D instance for projection */
|
|
632
|
+
camera?: any; // Camera3D from util
|
|
633
|
+
/** Enable depth sorting */
|
|
634
|
+
depthSort?: boolean;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* 3D scene with Camera3D projection support.
|
|
639
|
+
* Children with x, y, z positions are projected through the camera.
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* const camera = new Camera3D({ rotationX: 0.3, perspective: 800 });
|
|
643
|
+
* const scene3d = new Scene3D(game, { camera });
|
|
644
|
+
* scene3d.add(myObject);
|
|
645
|
+
*/
|
|
646
|
+
export class Scene3D extends Scene {
|
|
647
|
+
/** Camera3D instance */
|
|
648
|
+
camera: any;
|
|
649
|
+
/** Whether to depth sort children */
|
|
650
|
+
depthSort: boolean;
|
|
651
|
+
|
|
652
|
+
constructor(game: Game, options?: Scene3DOptions);
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Project a 3D point through the camera.
|
|
656
|
+
* @param x - X coordinate
|
|
657
|
+
* @param y - Y coordinate
|
|
658
|
+
* @param z - Z coordinate
|
|
659
|
+
*/
|
|
660
|
+
project(x: number, y: number, z: number): { x: number; y: number; z: number; scale: number };
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// ==========================================================================
|
|
664
|
+
// IsometricScene
|
|
665
|
+
// ==========================================================================
|
|
666
|
+
|
|
667
|
+
/** Options for IsometricScene */
|
|
668
|
+
export interface IsometricSceneOptions extends SceneOptions {
|
|
669
|
+
/** Isometric camera instance */
|
|
670
|
+
camera?: any; // IsometricCamera from util
|
|
671
|
+
/** Tile width */
|
|
672
|
+
tileWidth?: number;
|
|
673
|
+
/** Tile height */
|
|
674
|
+
tileHeight?: number;
|
|
675
|
+
/** Grid columns */
|
|
676
|
+
cols?: number;
|
|
677
|
+
/** Grid rows */
|
|
678
|
+
rows?: number;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Isometric scene with 2.5D grid projection.
|
|
683
|
+
* Converts grid coordinates to isometric screen positions.
|
|
684
|
+
*
|
|
685
|
+
* @example
|
|
686
|
+
* const isoScene = new IsometricScene(game, {
|
|
687
|
+
* tileWidth: 64,
|
|
688
|
+
* tileHeight: 32,
|
|
689
|
+
* cols: 10,
|
|
690
|
+
* rows: 10
|
|
691
|
+
* });
|
|
692
|
+
*/
|
|
693
|
+
export class IsometricScene extends Scene {
|
|
694
|
+
/** Tile width */
|
|
695
|
+
tileWidth: number;
|
|
696
|
+
/** Tile height */
|
|
697
|
+
tileHeight: number;
|
|
698
|
+
/** Grid columns */
|
|
699
|
+
cols: number;
|
|
700
|
+
/** Grid rows */
|
|
701
|
+
rows: number;
|
|
702
|
+
/** Isometric camera */
|
|
703
|
+
camera: any;
|
|
704
|
+
|
|
705
|
+
constructor(game: Game, options?: IsometricSceneOptions);
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Convert grid coordinates to screen position.
|
|
709
|
+
* @param gridX - Grid X coordinate
|
|
710
|
+
* @param gridY - Grid Y coordinate
|
|
711
|
+
* @param height - Optional height offset
|
|
712
|
+
*/
|
|
713
|
+
gridToScreen(gridX: number, gridY: number, height?: number): { x: number; y: number };
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Convert screen position to grid coordinates.
|
|
717
|
+
* @param screenX - Screen X coordinate
|
|
718
|
+
* @param screenY - Screen Y coordinate
|
|
719
|
+
*/
|
|
720
|
+
screenToGrid(screenX: number, screenY: number): { x: number; y: number };
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// ==========================================================================
|
|
724
|
+
// FluidSystem
|
|
725
|
+
// ==========================================================================
|
|
726
|
+
|
|
727
|
+
/** Options for FluidSystem */
|
|
728
|
+
export interface FluidSystemOptions extends GameObjectOptions {
|
|
729
|
+
/** Maximum number of particles */
|
|
730
|
+
maxParticles?: number;
|
|
731
|
+
/** Particle radius */
|
|
732
|
+
particleRadius?: number;
|
|
733
|
+
/** Gravity strength */
|
|
734
|
+
gravity?: number;
|
|
735
|
+
/** Fluid viscosity */
|
|
736
|
+
viscosity?: number;
|
|
737
|
+
/** Pressure multiplier */
|
|
738
|
+
pressure?: number;
|
|
739
|
+
/** Surface tension */
|
|
740
|
+
surfaceTension?: number;
|
|
741
|
+
/** Boundary bounds */
|
|
742
|
+
bounds?: { x: number; y: number; width: number; height: number };
|
|
743
|
+
/** Particle color */
|
|
744
|
+
color?: string | ((particle: any) => string);
|
|
745
|
+
/** Canvas blend mode */
|
|
746
|
+
blendMode?: GlobalCompositeOperation;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Fluid simulation system using SPH (Smoothed Particle Hydrodynamics).
|
|
751
|
+
*
|
|
752
|
+
* @example
|
|
753
|
+
* const fluid = new FluidSystem(game, {
|
|
754
|
+
* maxParticles: 500,
|
|
755
|
+
* gravity: 200,
|
|
756
|
+
* viscosity: 0.1,
|
|
757
|
+
* bounds: { x: 0, y: 0, width: 800, height: 600 }
|
|
758
|
+
* });
|
|
759
|
+
* game.pipeline.add(fluid);
|
|
760
|
+
*/
|
|
761
|
+
export class FluidSystem extends GameObject {
|
|
762
|
+
/** All fluid particles */
|
|
763
|
+
particles: any[];
|
|
764
|
+
/** Maximum particles */
|
|
765
|
+
maxParticles: number;
|
|
766
|
+
/** Particle radius */
|
|
767
|
+
particleRadius: number;
|
|
768
|
+
/** Gravity strength */
|
|
769
|
+
gravity: number;
|
|
770
|
+
/** Fluid viscosity */
|
|
771
|
+
viscosity: number;
|
|
772
|
+
/** Pressure multiplier */
|
|
773
|
+
pressure: number;
|
|
774
|
+
|
|
775
|
+
/** Current particle count */
|
|
776
|
+
readonly particleCount: number;
|
|
777
|
+
|
|
778
|
+
constructor(game: Game, options?: FluidSystemOptions);
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Spawn particles at position.
|
|
782
|
+
* @param x - X position
|
|
783
|
+
* @param y - Y position
|
|
784
|
+
* @param count - Number of particles
|
|
785
|
+
* @param spread - Position spread
|
|
786
|
+
*/
|
|
787
|
+
spawn(x: number, y: number, count: number, spread?: number): void;
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Apply force to particles in radius.
|
|
791
|
+
* @param x - Force center X
|
|
792
|
+
* @param y - Force center Y
|
|
793
|
+
* @param radius - Effect radius
|
|
794
|
+
* @param force - Force strength
|
|
795
|
+
*/
|
|
796
|
+
applyForce(x: number, y: number, radius: number, force: number): void;
|
|
797
|
+
|
|
798
|
+
/** Clear all particles */
|
|
799
|
+
clear(): void;
|
|
800
|
+
}
|