-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
111 lines (90 loc) · 2.67 KB
/
index.d.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
declare module "pixel-eight" {
export interface Buttons {
up: boolean;
down: boolean;
left: boolean;
right: boolean;
a: boolean;
b: boolean;
j: boolean;
}
export interface ButtonData {
/** The buttons that are currently pressed */
pressed: Buttons;
/** The buttons that were pressed during the tick */
clicked: Buttons;
}
export interface Colors {
black: number;
darkblue: number;
purple: number;
darkgreen: number;
brown: number;
darkgrey: number;
lightgrey: number;
white: number;
red: number;
orange: number;
yellow: number;
green: number;
lightblue: number;
bluegrey: number;
pink: number;
beige: number;
}
export const colors: Colors;
export interface Map {
/** The width of the map */
width: number;
/** The height of the map */
height: number;
/** Set a pixel in the map to the color */
pset(x, y, color: number): undefined;
/** Get the color of a pixel in the map */
pget(x, y): number;
}
/** The Frame represents the screen of the pixel */
export interface Frame {
/** Color a single pixel at the point (x,y) with the color c */
pset(x: number, y: number, color: number): undefined;
/** Draw a map to the screen offseting into it using the x / y */
mset(x: number, y: number, map: Map, transparent?: number): undefined;
/** Draw a bitmap from an exported animation */
bset(bitmap: string[], transparent?: string);
/** Clear the screen (color black if unspecified) */
cls(color?: number): undefined;
/** Draw a rectangle on the screen */
rect(
x1: number,
y1: number,
x2: number,
y2: number,
color: number
): undefined;
/** Fill in a rectangle on the screen (defaults to black) */
fill(
x1: number,
y1: number,
x2: number,
y2: number,
color?: number
): undefined;
/** Write text to the screen at the given co-ordinates */
print(text: string, x?: number, y?: number, color?: number);
}
/** Interface for specifying a game */
export interface Game<T> {
/** Initialize the game - called once */
init?(): T;
/** Update the game state - called once per frame */
update?(state: T, buttons: Buttons, ticks: number): T;
/** Draw to the screen - called once per frame */
draw(frame: Frame, state: T): undefined;
/** The frame rate - defaults 10 frames per second */
frameRate?: number;
}
/** Create a map from an array of strings of hex colors */
export function createMap(hexMap: string[]): Map;
/** Start the game running */
export function start(game: Game): undefined;
}