UNPKG

@knopkem/little-game-engine-ts

Version:

LittleGameEngineTS - Tiny and Fast HTML5 Game Engine typescript port of LittleJS

44 lines (43 loc) 3.02 kB
/** Name of engine */ export declare const engineName = "LittleJS"; /** Version of engine */ export declare const engineVersion = "1.1.2"; /** Frames per second to update objects * @default */ export declare const FPS = 60; /** How many seconds each frame lasts, engine uses a fixed time step * @default 1/60 */ export declare const timeDelta: number; /** Array containing all engine objects */ export declare let engineObjects: any; /** Array containing only objects that are set to collide with other objects (for optimization) */ export declare let engineCollideObjects: any; /** Current update frame, used to calculate time */ export declare let frame: number; /** Current engine time since start in seconds, derived from frame */ export declare let time: number; /** Actual clock time since start in seconds (not affected by pause or frame rate clamping) */ export declare let timeReal: number; /** Is the game paused? Causes time and objects to not be updated. */ export declare let paused: number; export declare let frameTimeLastMS: number, frameTimeBufferMS: number, debugFPS: number, shrinkTilesX: number, shrinkTilesY: number, drawCount: any, tileImageSize: any, tileImageSizeInverse: any; export declare function setDrawCount(count: number): number; /** Start up LittleJS engine with your callback functions * @param {Function} gameInit - Called once after the engine starts up, setup the game * @param {Function} gameUpdate - Called every frame at 60 frames per second, handle input and update the game state * @param {Function} gameUpdatePost - Called after physics and objects are updated, setup camera and prepare for render * @param {Function} gameRender - Called before objects are rendered, draw any background effects that appear behind objects * @param {Function} gameRenderPost - Called after objects are rendered, draw effects or hud that appear above all objects * @param {String} tileImageSource - Tile image to use, everything starts when the image is finished loading */ export declare function engineInit(gameInit: any, gameUpdate: any, gameUpdatePost: any, gameRender: any, gameRenderPost: any, tileImageSource: any): void; /** Calls update on each engine object (recursively if child), removes destroyed objects, and updated time */ export declare function engineObjectsUpdate(): void; /** Detroy and remove all objects that are not persistent or descendants of a persistent object */ export declare function engineObjectsDestroy(): void; /** Triggers a callback for each object within a given area * @param {Vector2} [pos] - Center of test area * @param {Number} [size] - Radius of circle if float, rectangle size if Vector2 * @param {Function} [callbackFunction] - Calls this function on every object that passes the test * @param {Array} [objects=engineObjects] - List of objects to check */ export declare function engineObjectsCallback(pos: any, size: any, callbackFunction: any, objects?: any): void;