minimojs 1.0.0-alpha.4 → 1.0.0-alpha.40
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 +374 -0
- package/dist/minimo-multiplayer.js +1310 -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,199 @@
|
|
|
1
|
+
import { Game } from "./minimo.js";
|
|
2
|
+
/**
|
|
3
|
+
* When a leaderboard starts again. Every period is a UTC calendar unit, and a
|
|
4
|
+
* week is an ISO week, starting on Monday, so every player sees the table
|
|
5
|
+
* reset at the same moment. Past periods stay readable.
|
|
6
|
+
*/
|
|
7
|
+
export type LeaderboardCycle = "never" | "daily" | "weekly" | "monthly" | "yearly";
|
|
8
|
+
/** Which score is better: `higher`, for points, or `lower`, for times. */
|
|
9
|
+
export type LeaderboardOrder = "higher" | "lower";
|
|
10
|
+
/**
|
|
11
|
+
* What a leaderboard's table calls each player: `player`, the name the player
|
|
12
|
+
* wrote, or `noname`; `hidden`, no names; or `assigned`, a name such as
|
|
13
|
+
* `Blue Fox 42`, given to each player.
|
|
14
|
+
*/
|
|
15
|
+
export type LeaderboardNames = "player" | "hidden" | "assigned";
|
|
16
|
+
/**
|
|
17
|
+
* Who can be in a leaderboard. `account`: players signed in to Minimo Games,
|
|
18
|
+
* in one table every player sees. `local`: light users, whose scores stay on
|
|
19
|
+
* their own device, so each player sees only their own.
|
|
20
|
+
*/
|
|
21
|
+
export type LeaderboardPlayer = "account" | "local";
|
|
22
|
+
/**
|
|
23
|
+
* How a leaderboard works. On Minimo Games the creator sets these on the
|
|
24
|
+
* game's Edit leaderboards page, or an AI agent sets them with the
|
|
25
|
+
* `saveGameLeaderboard` tool, and the game reads them; the settings passed to
|
|
26
|
+
* {@link Leaderboard} are used only when the game runs anywhere else.
|
|
27
|
+
*/
|
|
28
|
+
export interface LeaderboardSettings {
|
|
29
|
+
/** The title its table shows. */
|
|
30
|
+
title: string;
|
|
31
|
+
cycle: LeaderboardCycle;
|
|
32
|
+
order: LeaderboardOrder;
|
|
33
|
+
names: LeaderboardNames;
|
|
34
|
+
player: LeaderboardPlayer;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Which period of a leaderboard to read: `"current"` (the default),
|
|
38
|
+
* `"previous"`, such as yesterday's table of a daily leaderboard, or a period
|
|
39
|
+
* written out: `"2026-10-17"`, `"2026-W42"`, `"2026-10"`, or `"2026"`.
|
|
40
|
+
*/
|
|
41
|
+
export type LeaderboardPeriod = "current" | "previous" | string;
|
|
42
|
+
/** One row of a leaderboard's table. */
|
|
43
|
+
export interface LeaderboardEntry {
|
|
44
|
+
/** 1 for the best score. Equal scores share a rank. */
|
|
45
|
+
rank: number;
|
|
46
|
+
/** The player's name, or `null` when the leaderboard shows no names. */
|
|
47
|
+
name: string | null;
|
|
48
|
+
score: number;
|
|
49
|
+
/** Whether this is the player playing now. */
|
|
50
|
+
mine: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** One period of a leaderboard, best score first. */
|
|
53
|
+
export interface LeaderboardTable {
|
|
54
|
+
key: string;
|
|
55
|
+
settings: LeaderboardSettings;
|
|
56
|
+
/** The period read, or `null` for the period before a leaderboard that never resets. */
|
|
57
|
+
period: string | null;
|
|
58
|
+
entries: LeaderboardEntry[];
|
|
59
|
+
/** The player's own entry in the period, wherever it ranks, or `null`. */
|
|
60
|
+
mine: LeaderboardEntry | null;
|
|
61
|
+
/**
|
|
62
|
+
* `false` when the leaderboard does not exist, such as a key no leaderboard
|
|
63
|
+
* of the game has. The table is then empty.
|
|
64
|
+
*/
|
|
65
|
+
available: boolean;
|
|
66
|
+
/** Whether the scores are kept on this device rather than by Minimo Games. */
|
|
67
|
+
local: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* What became of a score:
|
|
71
|
+
*
|
|
72
|
+
* - `saved`: it is the player's best in the period, and the table shows it.
|
|
73
|
+
* - `not_better`: the player already has a better score in the period.
|
|
74
|
+
* - `pending_sign_in`: the leaderboard takes Minimo Games accounts and the
|
|
75
|
+
* player is not signed in. Minimo Games asks them to sign in, keeps the
|
|
76
|
+
* score, and saves it when they come back.
|
|
77
|
+
* - `unavailable`: the leaderboard does not exist, or the game is not taking
|
|
78
|
+
* new records now.
|
|
79
|
+
*/
|
|
80
|
+
export type LeaderboardSubmitStatus = "saved" | "not_better" | "pending_sign_in" | "unavailable";
|
|
81
|
+
export interface LeaderboardSubmitResult {
|
|
82
|
+
status: LeaderboardSubmitStatus;
|
|
83
|
+
/** The player's best score in the period, or `null` when nothing was saved. */
|
|
84
|
+
best: number | null;
|
|
85
|
+
/** The rank of that best score, or `null` when nothing was saved. */
|
|
86
|
+
rank: number | null;
|
|
87
|
+
period: string | null;
|
|
88
|
+
}
|
|
89
|
+
/** Options for {@link Leaderboard.top}. */
|
|
90
|
+
export interface LeaderboardTopOptions {
|
|
91
|
+
/** Which period to read. Default `"current"`. */
|
|
92
|
+
period?: LeaderboardPeriod;
|
|
93
|
+
}
|
|
94
|
+
/** Options for {@link Leaderboard.show}. Every field is optional. */
|
|
95
|
+
export interface LeaderboardShowOptions {
|
|
96
|
+
/** How many of the best scores the table shows. Default `10`, at most `100`. */
|
|
97
|
+
top?: number;
|
|
98
|
+
/** Which period the table opens on. Default `"current"`; the player can switch to the previous one. */
|
|
99
|
+
period?: LeaderboardPeriod;
|
|
100
|
+
/** A title instead of the leaderboard's own. */
|
|
101
|
+
title?: string;
|
|
102
|
+
/** How a score is written, such as `(s) => s.toFixed(2) + " s"`. Default: the number, with digit grouping. */
|
|
103
|
+
format?: (score: number) => string;
|
|
104
|
+
/** CSS font family, such as one of the game's fonts. Default: the system font. */
|
|
105
|
+
font?: string;
|
|
106
|
+
/** Background color of the table. Default `"#15151d"`. */
|
|
107
|
+
background?: string;
|
|
108
|
+
/** Text color. Default `"#ffffff"`. */
|
|
109
|
+
color?: string;
|
|
110
|
+
/** Color of the title and of the player's own row. Default `"#ffcc33"`. */
|
|
111
|
+
accent?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A leaderboard of the game: a table of each player's best score, per period.
|
|
115
|
+
*
|
|
116
|
+
* On Minimo Games, the creator sets up a game's leaderboards, up to 5, on the
|
|
117
|
+
* game's Edit leaderboards page, or an AI agent with the `saveGameLeaderboard`
|
|
118
|
+
* tool; the game names one by its key. Their settings come from there, and a
|
|
119
|
+
* key that no leaderboard of the game has is unavailable. Leaderboards are part
|
|
120
|
+
* of Minimo Games Pro: while the creator is not on it, the game shows its
|
|
121
|
+
* tables but saves no new records.
|
|
122
|
+
*
|
|
123
|
+
* Scores of a leaderboard that takes Minimo Games accounts go to one table
|
|
124
|
+
* that every player sees. Minimo Games posts them for the signed-in player, and
|
|
125
|
+
* asks a player who is not signed in to sign in, keeping the score until they
|
|
126
|
+
* do. Scores of a leaderboard for light users stay on the device, and a game
|
|
127
|
+
* preview keeps every score on the device, so a working version never changes
|
|
128
|
+
* the published game's tables.
|
|
129
|
+
*
|
|
130
|
+
* Anywhere else, every leaderboard keeps its scores on the device, with the
|
|
131
|
+
* settings passed here.
|
|
132
|
+
*
|
|
133
|
+
* Nothing here pauses the game. Await {@link Leaderboard.show} to continue
|
|
134
|
+
* after the player closes the table.
|
|
135
|
+
*
|
|
136
|
+
* ```js
|
|
137
|
+
* import { Leaderboard } from "https://cdn.jsdelivr.net/npm/minimojs@<version>/dist/minimo-leaderboard.js";
|
|
138
|
+
*
|
|
139
|
+
* const best = new Leaderboard(game, "best-score");
|
|
140
|
+
* // When a run ends:
|
|
141
|
+
* await best.submit(score);
|
|
142
|
+
* await best.show({ top: 10 });
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export declare class Leaderboard {
|
|
146
|
+
/** The key the game names this leaderboard by. */
|
|
147
|
+
readonly key: string;
|
|
148
|
+
/**
|
|
149
|
+
* @param game - The game.
|
|
150
|
+
* @param key - The leaderboard's key, as set up on Minimo Games.
|
|
151
|
+
* @param settings - Used only when the game runs outside Minimo Games.
|
|
152
|
+
* Default: a leaderboard on the device that never resets, where higher is
|
|
153
|
+
* better and players are named by their own name.
|
|
154
|
+
*/
|
|
155
|
+
constructor(game: Game, key: string, settings?: Partial<LeaderboardSettings>);
|
|
156
|
+
/** Whether the table is showing. */
|
|
157
|
+
get isShowing(): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* This leaderboard's settings, and whether it exists and keeps its scores on
|
|
160
|
+
* the device.
|
|
161
|
+
*/
|
|
162
|
+
info(): Promise<{
|
|
163
|
+
settings: LeaderboardSettings;
|
|
164
|
+
available: boolean;
|
|
165
|
+
local: boolean;
|
|
166
|
+
}>;
|
|
167
|
+
/**
|
|
168
|
+
* Posts a score. Only the player's best score in the current period is
|
|
169
|
+
* kept, so posting every finished run is right.
|
|
170
|
+
*
|
|
171
|
+
* @param score - A finite number. Which is better, higher or lower, is the
|
|
172
|
+
* leaderboard's setting.
|
|
173
|
+
*/
|
|
174
|
+
submit(score: number): Promise<LeaderboardSubmitResult>;
|
|
175
|
+
/**
|
|
176
|
+
* Reads one period of the table, best score first.
|
|
177
|
+
*
|
|
178
|
+
* @param limit - How many of the best scores. Default `10`, at most `100`.
|
|
179
|
+
*/
|
|
180
|
+
top(limit?: number, options?: LeaderboardTopOptions): Promise<LeaderboardTable>;
|
|
181
|
+
/**
|
|
182
|
+
* The light user's name on this device, shared by every Minimo Games game,
|
|
183
|
+
* or `null` before the player writes one. The table asks for it on its own
|
|
184
|
+
* when a leaderboard for light users shows names.
|
|
185
|
+
*/
|
|
186
|
+
playerName(): Promise<string | null>;
|
|
187
|
+
/** Sets the light user's name on this device. Returns it cleaned, or `null` when it is empty or too long. */
|
|
188
|
+
setPlayerName(name: string): Promise<string | null>;
|
|
189
|
+
/**
|
|
190
|
+
* Shows the table over the game, in HTML: the best scores of a period, the
|
|
191
|
+
* player's own entry, and, for a leaderboard that resets, a switch to the
|
|
192
|
+
* previous period. Resolves when the player closes it.
|
|
193
|
+
*/
|
|
194
|
+
show(options?: LeaderboardShowOptions): Promise<void>;
|
|
195
|
+
/** Closes the table, if it is showing. */
|
|
196
|
+
close(): void;
|
|
197
|
+
/** Closes the table. The leaderboard's scores are kept. */
|
|
198
|
+
destroy(): void;
|
|
199
|
+
}
|