-
Notifications
You must be signed in to change notification settings - Fork 33
/
game.ts
58 lines (48 loc) · 1.56 KB
/
game.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { DefaultInput } from "./defaultinput";
import { NetplayPlayer, NetplayState } from "./netcode/types";
import { TouchControl } from "./touchcontrols";
export type GameClass = {
new (canvas: HTMLCanvasElement, players: Array<NetplayPlayer>): Game;
/**
* The length of a single timestep in milliseconds.
*/
timestep: number;
/**
* NOT SUPPORTED YET.
*/
numPlayers?: number | { min: number; max: number };
/**
* Canvases need to have a fixed pixel size. This allows us to normalize
* mouse position and touches across the network.
*/
canvasSize: { width: number; height: number };
/**
* Should we scale up the canvas with the device pixel ratio?
* If enabled, it is up to the game code to draw correctly
* using window.devicePixelRatio.
*/
highDPI?: boolean;
/**
* Whether or not we should lock the pointer when the user clicks on the
* canvas. Use this for games like FPSs.
*/
pointerLock?: boolean;
/**
* Whether or not we should prevent the context menu from appearing when
* the user right clicks on the canvas.
*/
preventContextMenu?: boolean;
/**
* A list of all the touch controls needed for this game. These will
* only be shown on mobile.
*/
touchControls?: { [name: string]: TouchControl };
/**
* Is the game deterministic? By default, we assume no. If this is true,
* certain netcode algorithms can perform more efficiently.
*/
deterministic?: boolean;
};
export abstract class Game extends NetplayState<DefaultInput> {
abstract draw(canvas: HTMLCanvasElement);
}