blaze-2d
Version:
A fast and simple WebGL 2 2D game engine written in TypeScript
39 lines (38 loc) • 1.17 kB
TypeScript
import Entity from "./entity";
import Camera from "./camera/camera";
import { vec2 } from "gl-matrix";
export interface PlayerKeyMap {
forward?: string;
back?: string;
left?: string;
right?: string;
sprint?: string;
}
/**
* A highly customizable player controller.
*/
export default class Player extends Entity {
private camera;
keys: PlayerKeyMap;
/**
* Creates a {@link Player} instance with the given settings.
*
* @param pos The player's initial world position
* @param dimensions The width and height of the player's bounding box and body
* @param cameraViewport The width and height of the player camera's viewport
* @param keys The key map to use for player controls
*/
constructor(pos: vec2, dimensions: vec2, cameraViewport: vec2, keys?: PlayerKeyMap);
/**
* Updates the player's camera, rotation, velocity and picks blocks if block picking is enabled.
*
* @param delta The time since the last tick in ms
*/
update(delta: number): void;
/**
* Gets the player's current camera.
*
* @returns The player's camera
*/
getCamera(): Camera;
}