UNPKG

html2d

Version:

A Typescript game engine to build HTML5 games for the web using webcomponents.

44 lines (37 loc) 822 B
export enum AxisName { Horizontal = "Horizontal", Vertical = "Vertical" } export enum KeyCode { Space = "space", LeftArrow = "", UpArrow = "", DownArrow = "", RightArrow = "", Q = "q", W = "w", E = "e", R = "r", A = "a", S = "s", D = "d", Mouse0 = "", Mouse1 = "", } export class Input2D { static getAxis(direction: "Horizontal" | "Vertical") { if (direction === AxisName.Horizontal) { return 1 } if (direction === AxisName.Vertical) { return -1 } console.error(`${direction} is not a valid axis name.`) } static getKeyDown(key: string) { return true } static getKeyUp(key: string) { return true } }