Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 21x | import {
BE_MUSIC_SKIN_API_VERSION,
defineBeMusicSkin,
cabinetStage,
tallStage,
type BeMusicSkin,
type BeMusicSurface,
} from '@be-music/player-skin-sdk';
import { drawPlayfield } from './playfield.ts';
import { mountSelect } from './select.ts';
import { mountGameplay } from './play.ts';
import { mountDecide, mountResult } from './result.ts';
/**
* Responsive native screens and HUD. The playfield, BGA included, is a set of components, each drawing on a canvas the
* size of its part of the stage, so the player's own canvas is not used.
*/
export const nativeSkin: BeMusicSkin = defineBeMusicSkin({
apiVersion: BE_MUSIC_SKIN_API_VERSION,
version: '1.0.0',
author: { name: 'Be-Music' },
license: 'MIT',
fontLoads: [],
context: '2d',
// Landscape play in the cabinet layout; the touch layout keeps its lanes and HUD column.
stage: {
...cabinetStage,
playfield: { ...cabinetStage.playfield, touch: { top: 8, judgementY: 424, maxRight: 540 } },
},
portraitStage: {
...tallStage,
playfield: {
standard: { top: 224, judgementY: 838 },
touch: { top: 224, judgementY: 754 },
},
// Gameplay gets the height; BGA remains available in the right side of the compact header.
resolveBGARect: () => ({ x: 378, y: 8, w: 96, h: 96 }),
},
select: { layout: { listX: 0, listTop: 0, listBottomInset: 0, rowHeight: 40 }, draw: drawDOMRequired },
result: { draw: drawDOMRequired },
id: 'native',
label: 'Native (DOM + Canvas)',
description: 'Native HTML collection, settings, results and score HUD with a playfield of canvas components.',
gameplay: {
draw: drawPlayfield,
drawsOnDOM: true,
drawsBGA: true,
drawsMines: true,
drawsLaneCover: true,
drawsMeasureLines: true,
},
decide: { durationMs: 2000, draw: drawDOMRequired },
dom: { select: mountSelect, gameplay: mountGameplay, decide: mountDecide, result: mountResult },
});
/** Older hosts can show a readable capability notice instead of an empty screen. */
function drawDOMRequired({ context, width, height }: BeMusicSurface<'2d'>): void {
context.fillStyle = '#171717';
context.fillRect(0, 0, width, height);
context.fillStyle = '#edf2fa';
context.font = '20px system-ui';
context.textAlign = 'center';
context.fillText('Native requires a DOM-capable BeMusicSkin host.', width / 2, height / 2);
}
|