refactor(onitama): centralize visual constants in config

Introduce `TEXT_POSITION` and `VISUAL` objects to the configuration
to manage magic numbers for positioning, radii, stroke widths, and
alphas. Update renderers and spawners to use these constants instead
of hardcoded values or direct calculations.
This commit is contained in:
2026-04-20 16:04:29 +08:00
parent 22817945cc
commit 368d9942d2
9 changed files with 102 additions and 19 deletions
@@ -10,6 +10,8 @@ import {
COLORS,
FONTS,
MENU_BUTTON,
TEXT_POSITION,
VISUAL,
getBoardCenter,
getCardLabelPosition,
colorToStr,
@@ -79,7 +81,12 @@ export class OnitamaScene extends GameHostScene<OnitamaState> {
});
// Info text
this.infoText = this.add.text(40, BOARD_OFFSET.y, "", FONTS.info);
this.infoText = this.add.text(
TEXT_POSITION.infoX,
BOARD_OFFSET.y,
"",
FONTS.info,
);
// Update info text when UI state changes
this.addEffect(() => {
@@ -149,7 +156,12 @@ export class OnitamaScene extends GameHostScene<OnitamaState> {
g.strokePath();
this.add.text(40, 40, "Onitama", FONTS.title);
this.add.text(
TEXT_POSITION.titleX,
TEXT_POSITION.titleY,
"Onitama",
FONTS.title,
);
}
private setupInput(): void {
@@ -288,7 +300,7 @@ export class OnitamaScene extends GameHostScene<OnitamaState> {
boardWidth,
boardHeight,
COLORS.overlayBg,
0.6,
VISUAL.overlayAlpha,
)
.setInteractive({ useHandCursor: true });