minimojs 1.0.0-alpha.4 → 1.0.0-alpha.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -20
- package/dist/internal/AnimationSystem.js +345 -0
- package/dist/internal/AssetSystem.d.ts +6 -0
- package/dist/internal/AssetSystem.js +281 -0
- package/dist/internal/BackgroundSystem.d.ts +1 -0
- package/dist/internal/BackgroundSystem.js +26 -0
- package/dist/internal/CanvasSystem.d.ts +1 -0
- package/dist/internal/CanvasSystem.js +51 -0
- package/dist/internal/DesignNamingCheck.d.ts +1 -0
- package/dist/internal/DesignNamingCheck.js +7 -0
- package/dist/internal/ExplosionSystem.d.ts +1 -0
- package/dist/internal/ExplosionSystem.js +540 -0
- package/dist/internal/InputSystem.d.ts +1 -0
- package/dist/internal/InputSystem.js +292 -0
- package/dist/internal/LoopSystem.d.ts +1 -0
- package/dist/internal/LoopSystem.js +61 -0
- package/dist/internal/PhysicsSystem.d.ts +1 -0
- package/dist/internal/PhysicsSystem.js +174 -0
- package/dist/internal/RenderSystem.d.ts +1 -0
- package/dist/internal/RenderSystem.js +1021 -0
- package/dist/internal/SoundSystem.d.ts +39 -0
- package/dist/internal/SoundSystem.js +292 -0
- package/dist/internal/SpriteSystem.d.ts +1 -0
- package/dist/internal/SpriteSystem.js +32 -0
- package/dist/internal/TextSystem.d.ts +1 -0
- package/dist/internal/TextSystem.js +16 -0
- package/dist/internal/TimerSystem.d.ts +1 -0
- package/dist/internal/TimerSystem.js +43 -0
- package/dist/internal/TrailSystem.d.ts +1 -0
- package/dist/internal/TrailSystem.js +116 -0
- package/dist/internal/TransitionSystem.d.ts +1 -0
- package/dist/internal/TransitionSystem.js +74 -0
- package/dist/internal/arcade-racer/ArcadeRacerCollisionSystem.d.ts +1 -0
- package/dist/internal/arcade-racer/ArcadeRacerCollisionSystem.js +198 -0
- package/dist/internal/arcade-racer/ArcadeRacerLaneSystem.d.ts +1 -0
- package/dist/internal/arcade-racer/ArcadeRacerLaneSystem.js +120 -0
- package/dist/internal/arcade-racer/ArcadeRacerRenderSystem.d.ts +1 -0
- package/dist/internal/arcade-racer/ArcadeRacerRenderSystem.js +599 -0
- package/dist/internal/arcade-racer/ArcadeRacerRoadSprite.d.ts +1 -0
- package/dist/internal/arcade-racer/ArcadeRacerRoadSprite.js +13 -0
- package/dist/internal/arcade-racer/ArcadeRacerTrackSystem.d.ts +1 -0
- package/dist/internal/arcade-racer/ArcadeRacerTrackSystem.js +447 -0
- package/dist/minimo-ambient.d.ts +299 -0
- package/dist/minimo-ambient.js +1445 -0
- package/dist/minimo-arcaderacer.d.ts +1431 -0
- package/dist/minimo-arcaderacer.js +2060 -0
- package/dist/minimo-cards.d.ts +359 -0
- package/dist/minimo-cards.js +819 -0
- package/dist/minimo-dice.d.ts +206 -0
- package/dist/minimo-dice.js +719 -0
- package/dist/minimo-fire.d.ts +282 -0
- package/dist/minimo-fire.js +930 -0
- package/dist/minimo-format.d.ts +632 -0
- package/dist/minimo-format.js +669 -0
- package/dist/minimo-leaderboard.d.ts +199 -0
- package/dist/minimo-leaderboard.js +566 -0
- package/dist/minimo-multiplayer.d.ts +387 -0
- package/dist/minimo-multiplayer.js +1323 -0
- package/dist/minimo.d.ts +1690 -233
- package/dist/minimo.js +2587 -892
- package/package.json +10 -3
- package/dist/animations.js +0 -30
- package/dist/audio.js +0 -17
- package/dist/game.js +0 -1105
- package/dist/input.js +0 -185
- package/dist/internal-types.js +0 -4
- package/dist/physics.js +0 -10
- package/dist/render.js +0 -75
- package/dist/sprite.js +0 -149
- package/dist/timers.js +0 -23
- /package/dist/{pointer-info.js → internal/AnimationSystem.d.ts} +0 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { DrawSprite, Game } from "./minimo.js";
|
|
2
|
+
/** The kinds of die a {@link Dice} set makes: a d4, d6, d8, d10, d12, or d20. */
|
|
3
|
+
export type DieSides = 4 | 6 | 8 | 10 | 12 | 20;
|
|
4
|
+
/**
|
|
5
|
+
* How a die turns, in degrees per second about the screen's three axes.
|
|
6
|
+
* The sign is the direction and the size is the speed.
|
|
7
|
+
*
|
|
8
|
+
* - `x`: positive turns the die's top toward the player.
|
|
9
|
+
* - `y`: positive turns the die's front to the right.
|
|
10
|
+
* - `z`: positive turns the die clockwise, as `Sprite.rotation` does.
|
|
11
|
+
*/
|
|
12
|
+
export interface DieSpin {
|
|
13
|
+
x?: number;
|
|
14
|
+
y?: number;
|
|
15
|
+
z?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The look of a die. A {@link Dice} set holds one for all its dice, and each
|
|
19
|
+
* die can override any field.
|
|
20
|
+
*/
|
|
21
|
+
export interface DieLook {
|
|
22
|
+
/** Color of the die's body. Default `"#f4f1ea"`. */
|
|
23
|
+
color?: string;
|
|
24
|
+
/** Color of the die's edges. Default `"rgba(0, 0, 0, 0.35)"`. */
|
|
25
|
+
edgeColor?: string;
|
|
26
|
+
/** Color of the pips and numbers. Default `"#1b1f1d"`. */
|
|
27
|
+
markColor?: string;
|
|
28
|
+
/**
|
|
29
|
+
* How faces are marked: `"pips"` or `"numbers"`. Pips exist only on a d6,
|
|
30
|
+
* and are its default; every other die shows numbers. On a die with
|
|
31
|
+
* numbers, `6` and `9` are underlined, as on real dice.
|
|
32
|
+
*/
|
|
33
|
+
marks?: "pips" | "numbers";
|
|
34
|
+
/**
|
|
35
|
+
* CSS font family of the numbers, such as `'"Lilita One"'`. Use a web font
|
|
36
|
+
* the page declares and the game registers with `game.requireFont`, so the
|
|
37
|
+
* numbers look the same on every device. Default: the engine's default
|
|
38
|
+
* font, `monospace`. Pips are shapes and need no font.
|
|
39
|
+
*/
|
|
40
|
+
font?: string;
|
|
41
|
+
/** Font weight of the numbers. Default `"700"`. */
|
|
42
|
+
fontWeight?: string;
|
|
43
|
+
/** Body color of single faces, by value, over {@link DieLook.color}. */
|
|
44
|
+
faceColors?: Record<number, string>;
|
|
45
|
+
/**
|
|
46
|
+
* An image key for single faces, by value, drawn in place of that face's
|
|
47
|
+
* pips or number. On a d6 the image fills the face. On a d4, whose result is
|
|
48
|
+
* read at its top corner, it is drawn at the corner of that value on each
|
|
49
|
+
* face.
|
|
50
|
+
*/
|
|
51
|
+
faces?: Record<number, string>;
|
|
52
|
+
}
|
|
53
|
+
/** Where a new die is, how big, and how it looks. */
|
|
54
|
+
export interface DieOptions extends DieLook {
|
|
55
|
+
/** X position in world space (center), in pixels. Default `0`. */
|
|
56
|
+
x?: number;
|
|
57
|
+
/** Y position in world space (center), in pixels. Default `0`. */
|
|
58
|
+
y?: number;
|
|
59
|
+
/**
|
|
60
|
+
* About how wide the die is at rest, in pixels. Default `64`. It is also the
|
|
61
|
+
* die's collision body; its drawing surface is larger, to hold the die at
|
|
62
|
+
* every angle.
|
|
63
|
+
*/
|
|
64
|
+
size?: number;
|
|
65
|
+
/** The face shown at first. Default `1`. */
|
|
66
|
+
value?: number;
|
|
67
|
+
}
|
|
68
|
+
/** How {@link Die.roll} throws a die. */
|
|
69
|
+
export interface DieRollOptions {
|
|
70
|
+
/**
|
|
71
|
+
* The turning at the throw, which slows down to a stop. Default: the die's
|
|
72
|
+
* current spin while it turns, otherwise `{ x: 600, y: 420, z: 90 }`.
|
|
73
|
+
*/
|
|
74
|
+
spin?: DieSpin;
|
|
75
|
+
/** How long the roll takes, in milliseconds. Default `1000`. */
|
|
76
|
+
ms?: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A set of dice that share a look. It makes each die and advances all of them
|
|
80
|
+
* with one {@link Dice.update} call per frame.
|
|
81
|
+
*
|
|
82
|
+
* The set never decides a result: the game chooses each value, and the dice
|
|
83
|
+
* turn and land on it. The same value, spin, and duration turn a die the same
|
|
84
|
+
* way on every device, so a multiplayer room can put them in its shared state
|
|
85
|
+
* and every player sees the same roll.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const dice = new Dice(game, { color: "#f4f1ea", font: '"Lilita One"' });
|
|
90
|
+
* const d20 = dice.create(20, { x: 200, y: 300, size: 72 });
|
|
91
|
+
* game.onUpdate = (dt) => dice.update(dt);
|
|
92
|
+
*
|
|
93
|
+
* const value = 1 + Math.floor(game.random() * 20);
|
|
94
|
+
* await d20.roll(value, { spin: { x: 540, y: -360, z: 90 }, ms: 1200 });
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* ## In a design
|
|
98
|
+
*
|
|
99
|
+
* A design can place dice, so the creator moves them in the design editor. A
|
|
100
|
+
* die is a `module` object of a version 3 design whose `kind` is `"d4"`,
|
|
101
|
+
* `"d6"`, `"d8"`, `"d10"`, `"d12"`, or `"d20"`, and a design sets only its
|
|
102
|
+
* `x` and `y`. Its look and size are the set's, as for {@link Dice.create}
|
|
103
|
+
* without options, and it shows its 1 until the game rolls it.
|
|
104
|
+
*
|
|
105
|
+
* ```json
|
|
106
|
+
* { "id": "9a2c4e6f-1b3d-4f5a-8c7e-0d2f4b6a8c1e", "name": "d20", "type": "module", "module": "dice", "kind": "d20", "x": 360, "y": 640 }
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* Create the set in the scene's `onCreate()` before the design's objects,
|
|
110
|
+
* then find the die by its name:
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* onCreate() {
|
|
114
|
+
* this.dice = new Dice(game, { color: "#f4f1ea" });
|
|
115
|
+
* this.d20 = game.createObjectList(board.objects).findByName("d20");
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare class Dice {
|
|
120
|
+
/** The game the dice are added to. */
|
|
121
|
+
readonly game: Game;
|
|
122
|
+
/** The look every die of the set starts from. */
|
|
123
|
+
readonly look: DieLook;
|
|
124
|
+
constructor(game: Game, look?: DieLook);
|
|
125
|
+
/** The dice of this set, in the order they were made. */
|
|
126
|
+
get dice(): readonly Die[];
|
|
127
|
+
/**
|
|
128
|
+
* Makes a die, adds it to the game, and returns it. The die is a sprite: the
|
|
129
|
+
* game can move it, give it gravity, and test its collisions while it turns.
|
|
130
|
+
* @param sides - `4`, `6`, `8`, `10`, `12`, or `20`.
|
|
131
|
+
* @param options - Position, size, first face, and any look over the set's.
|
|
132
|
+
*/
|
|
133
|
+
create(sides: DieSides, options?: DieOptions): Die;
|
|
134
|
+
/** Removes a die from the game and from this set. */
|
|
135
|
+
remove(die: Die): void;
|
|
136
|
+
/**
|
|
137
|
+
* Advances every die of the set. Call it once per frame from `onUpdate`.
|
|
138
|
+
* A die the game destroyed, such as by `game.reset()`, leaves the set.
|
|
139
|
+
*/
|
|
140
|
+
update(dt: number): void;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* One die, drawn in simulated 3D: a real solid, turned, shaded, and projected
|
|
144
|
+
* onto the 2D canvas. It is a `DrawSprite`, so it has everything a sprite has.
|
|
145
|
+
* The module turns it in place; moving it is the game's, with the same
|
|
146
|
+
* physics as any other sprite.
|
|
147
|
+
*
|
|
148
|
+
* Make dice with {@link Dice.create}, which also advances them. A die made
|
|
149
|
+
* with `new Die` must be added with `game.add` and advanced with
|
|
150
|
+
* {@link Die.update} by the game.
|
|
151
|
+
*/
|
|
152
|
+
export declare class Die extends DrawSprite {
|
|
153
|
+
/** The kind of die: `4`, `6`, `8`, `10`, `12`, or `20`. */
|
|
154
|
+
readonly sides: DieSides;
|
|
155
|
+
/** About how wide the die is at rest, in pixels. */
|
|
156
|
+
readonly size: number;
|
|
157
|
+
/** Called with the value whenever the die comes to rest after turning. */
|
|
158
|
+
onLand: ((value: number) => void) | null;
|
|
159
|
+
/**
|
|
160
|
+
* @param sides - `4`, `6`, `8`, `10`, `12`, or `20`.
|
|
161
|
+
* @param options - Position, size, first face, and look.
|
|
162
|
+
*/
|
|
163
|
+
constructor(sides: DieSides, options?: DieOptions);
|
|
164
|
+
/** The look of this die. Change it with {@link Die.setLook}. */
|
|
165
|
+
get look(): Readonly<DieLook>;
|
|
166
|
+
/** Changes some of the die's look, keeping the rest. */
|
|
167
|
+
setLook(look: DieLook): void;
|
|
168
|
+
/**
|
|
169
|
+
* The value facing the player: the result once the die is at rest, and
|
|
170
|
+
* whatever face is in front while it turns. A d4 is read at its top corner,
|
|
171
|
+
* as a real one is: its value is the corner pointing up.
|
|
172
|
+
*/
|
|
173
|
+
get value(): number;
|
|
174
|
+
/** `true` while the die turns, from a spin or a roll until it lands. */
|
|
175
|
+
get rolling(): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Starts the die turning, or changes how it turns, and keeps it turning
|
|
178
|
+
* until {@link Die.land} or {@link Die.show}. A landing in progress stops,
|
|
179
|
+
* and the die turns freely again.
|
|
180
|
+
*/
|
|
181
|
+
spin(spin: DieSpin): void;
|
|
182
|
+
/**
|
|
183
|
+
* Slows the die down and settles it on `value`, upright, in `ms`. The die
|
|
184
|
+
* keeps the direction and speed it was turning at, and slows to a stop
|
|
185
|
+
* exactly on its face.
|
|
186
|
+
* @returns A promise that resolves with the value when the die is at rest.
|
|
187
|
+
*/
|
|
188
|
+
land(value: number, ms?: number): Promise<number>;
|
|
189
|
+
/**
|
|
190
|
+
* Throws the die: it starts turning with `spin` and lands on `value` after
|
|
191
|
+
* `ms`, slowing down all the way. This is the call most games need.
|
|
192
|
+
* @returns A promise that resolves with the value when the die is at rest.
|
|
193
|
+
*/
|
|
194
|
+
roll(value: number, options?: DieRollOptions): Promise<number>;
|
|
195
|
+
/**
|
|
196
|
+
* Turns the die to `value` at once, with no animation, such as when a game
|
|
197
|
+
* restores its state. A die that was turning stops.
|
|
198
|
+
*/
|
|
199
|
+
show(value: number): void;
|
|
200
|
+
/**
|
|
201
|
+
* Advances the die's turning. {@link Dice.update} calls it for every die of
|
|
202
|
+
* its set; call it yourself only for a die made with `new Die`.
|
|
203
|
+
*/
|
|
204
|
+
update(dt: number): void;
|
|
205
|
+
redraw(ctx: CanvasRenderingContext2D): void;
|
|
206
|
+
}
|