Add asset reaping
This commit is contained in:
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for the in-game developer console.
|
||||
*/
|
||||
interface ConsoleNamespace {
|
||||
/**
|
||||
* Prints one or more values to the in-game console, separated by tabs.
|
||||
* Each argument is coerced to a string before printing.
|
||||
*
|
||||
* @param args - Values to print.
|
||||
*
|
||||
* @example
|
||||
* Console.print("x =", player.x, "y =", player.y);
|
||||
*/
|
||||
print(...args: unknown[]): void;
|
||||
|
||||
/**
|
||||
* Whether the in-game console overlay is currently visible.
|
||||
* Set to `true` to show the console, `false` to hide it.
|
||||
*
|
||||
* @example
|
||||
* Console.visible = true;
|
||||
*/
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
/** In-game developer console. */
|
||||
declare var Console: ConsoleNamespace;
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* Controls over the engine main loop.
|
||||
*/
|
||||
interface EngineNamespace {
|
||||
/**
|
||||
* Whether the engine main loop is still running (read-only).
|
||||
* Becomes `false` after `Engine.exit()` is called.
|
||||
*
|
||||
* @example
|
||||
* while (Engine.running) { ... }
|
||||
*/
|
||||
readonly running: boolean;
|
||||
|
||||
/**
|
||||
* Requests an orderly shutdown of the engine.
|
||||
* Sets the internal running flag to `false`; the main loop exits at the end
|
||||
* of the current tick.
|
||||
*
|
||||
* @example
|
||||
* Engine.exit();
|
||||
*/
|
||||
exit(): void;
|
||||
}
|
||||
|
||||
/** Engine lifecycle controls. */
|
||||
declare var Engine: EngineNamespace;
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*
|
||||
* Root type declarations for the Dusk engine built-in JavaScript modules.
|
||||
* These globals are injected by the native JerryScript runtime — they are not
|
||||
* ES modules and cannot be imported.
|
||||
*
|
||||
* Reference this file from a jsconfig.json or tsconfig.json to get
|
||||
* IntelliSense across all game scripts:
|
||||
*
|
||||
* { "compilerOptions": { "typeRoots": ["./types"] } }
|
||||
*/
|
||||
|
||||
/// <reference path="./console.d.ts" />
|
||||
/// <reference path="./screen.d.ts" />
|
||||
/// <reference path="./engine.d.ts" />
|
||||
/// <reference path="./input.d.ts" />
|
||||
/// <reference path="./system.d.ts" />
|
||||
Vendored
+115
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* Opaque type alias for input action identifiers.
|
||||
* Use the `INPUT_ACTION_*` constants rather than raw numbers.
|
||||
*/
|
||||
type InputAction = number;
|
||||
|
||||
/**
|
||||
* Polling-based input queries and button rebinding.
|
||||
*/
|
||||
interface InputNamespace {
|
||||
/**
|
||||
* Returns `true` while the given action is held down this frame.
|
||||
*
|
||||
* @param action - An `INPUT_ACTION_*` constant.
|
||||
*
|
||||
* @example
|
||||
* if (Input.isDown(INPUT_ACTION_UP)) { player.moveUp(); }
|
||||
*/
|
||||
isDown(action: InputAction): boolean;
|
||||
|
||||
/**
|
||||
* Returns `true` if the given action was held down in the previous frame.
|
||||
*
|
||||
* @param action - An `INPUT_ACTION_*` constant.
|
||||
*/
|
||||
wasDown(action: InputAction): boolean;
|
||||
|
||||
/**
|
||||
* Returns `true` on the first frame the action transitions from up → down.
|
||||
*
|
||||
* @param action - An `INPUT_ACTION_*` constant.
|
||||
*
|
||||
* @example
|
||||
* if (Input.pressed(INPUT_ACTION_ACCEPT)) { confirmSelection(); }
|
||||
*/
|
||||
pressed(action: InputAction): boolean;
|
||||
|
||||
/**
|
||||
* Returns `true` on the first frame the action transitions from down → up.
|
||||
*
|
||||
* @param action - An `INPUT_ACTION_*` constant.
|
||||
*/
|
||||
released(action: InputAction): boolean;
|
||||
|
||||
/**
|
||||
* Returns the continuous (analog) value of an action in the range `0.0–1.0`.
|
||||
* Digital buttons return either `0` or `1`.
|
||||
*
|
||||
* @param action - An `INPUT_ACTION_*` constant.
|
||||
*
|
||||
* @example
|
||||
* const speed = Input.getValue(INPUT_ACTION_UP) * MAX_SPEED;
|
||||
*/
|
||||
getValue(action: InputAction): number;
|
||||
|
||||
/**
|
||||
* Returns a signed axis value in the range `-1.0–1.0`, derived from two
|
||||
* opposing actions: `getValue(pos) - getValue(neg)`.
|
||||
*
|
||||
* @param neg - Action mapped to the negative direction.
|
||||
* @param pos - Action mapped to the positive direction.
|
||||
*
|
||||
* @example
|
||||
* const moveX = Input.axis(INPUT_ACTION_LEFT, INPUT_ACTION_RIGHT);
|
||||
*/
|
||||
axis(neg: InputAction, pos: InputAction): number;
|
||||
|
||||
/**
|
||||
* Rebinds a physical button (by name) to a logical input action at runtime.
|
||||
* Throws if `buttonName` is unknown or `action` is out of range.
|
||||
*
|
||||
* @param buttonName - Platform-specific button identifier string (e.g. `"A"`, `"START"`).
|
||||
* @param action - Target `INPUT_ACTION_*` constant.
|
||||
*
|
||||
* @example
|
||||
* Input.bind("A", INPUT_ACTION_ACCEPT);
|
||||
*/
|
||||
bind(buttonName: string, action: InputAction): void;
|
||||
}
|
||||
|
||||
/** Polling-based input system. */
|
||||
declare var Input: InputNamespace;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Input action constants.
|
||||
// Injected as plain global variables by the engine at startup.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** Move / navigate upward. */
|
||||
declare var INPUT_ACTION_UP: InputAction;
|
||||
/** Move / navigate downward. */
|
||||
declare var INPUT_ACTION_DOWN: InputAction;
|
||||
/** Move / navigate left. */
|
||||
declare var INPUT_ACTION_LEFT: InputAction;
|
||||
/** Move / navigate right. */
|
||||
declare var INPUT_ACTION_RIGHT: InputAction;
|
||||
/** Confirm / accept the current selection. */
|
||||
declare var INPUT_ACTION_ACCEPT: InputAction;
|
||||
/** Cancel / go back. */
|
||||
declare var INPUT_ACTION_CANCEL: InputAction;
|
||||
/** Emergency quit (e.g. hold-to-exit on embedded platforms). */
|
||||
declare var INPUT_ACTION_RAGEQUIT: InputAction;
|
||||
/** Toggle the developer console overlay. */
|
||||
declare var INPUT_ACTION_CONSOLE: InputAction;
|
||||
/** Pointer / cursor horizontal position (analog). */
|
||||
declare var INPUT_ACTION_POINTERX: InputAction;
|
||||
/** Pointer / cursor vertical position (analog). */
|
||||
declare var INPUT_ACTION_POINTERY: InputAction;
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* Read-only information about the current display surface.
|
||||
*/
|
||||
interface ScreenNamespace {
|
||||
/** Current render-target width in pixels (read-only). */
|
||||
readonly width: number;
|
||||
|
||||
/** Current render-target height in pixels (read-only). */
|
||||
readonly height: number;
|
||||
|
||||
/**
|
||||
* Aspect ratio of the current render target: `width / height` (read-only).
|
||||
*
|
||||
* @example
|
||||
* if (Screen.aspect > 1) { /* landscape *\/ }
|
||||
*/
|
||||
readonly aspect: number;
|
||||
}
|
||||
|
||||
/** Current display / render-target dimensions. */
|
||||
declare var Screen: ScreenNamespace;
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* Runtime platform detection and system-level information.
|
||||
*/
|
||||
interface SystemNamespace {
|
||||
/**
|
||||
* Numeric identifier for the platform the engine is running on (read-only).
|
||||
* Compare against the `System.PLATFORM_*` constants.
|
||||
*
|
||||
* @example
|
||||
* if (System.platform === System.PLATFORM_PSP) { useLowResAssets(); }
|
||||
*/
|
||||
readonly platform: number;
|
||||
|
||||
/** Linux desktop. */
|
||||
readonly PLATFORM_LINUX: number;
|
||||
|
||||
/** Knulli handheld (Linux-based). */
|
||||
readonly PLATFORM_KNULLI: number;
|
||||
|
||||
/** Sony PlayStation Portable. */
|
||||
readonly PLATFORM_PSP: number;
|
||||
|
||||
/** Nintendo GameCube. */
|
||||
readonly PLATFORM_GAMECUBE: number;
|
||||
|
||||
/** Nintendo Wii. */
|
||||
readonly PLATFORM_WII: number;
|
||||
}
|
||||
|
||||
/** Platform detection and system-level information. */
|
||||
declare var System: SystemNamespace;
|
||||
Reference in New Issue
Block a user