breakout71/src/options.ts

60 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-03-07 20:18:18 +01:00
import { fitSize, gameCanvas } from "./game";
2025-03-07 11:34:11 +01:00
export const options = {
2025-03-07 20:18:18 +01:00
sound: {
default: true,
name: `Game sounds`,
help: `Can slow down some phones.`,
afterChange:()=>{},
2025-03-07 20:18:18 +01:00
disabled: () => false,
},
"mobile-mode": {
default: window.innerHeight > window.innerWidth,
name: `Mobile mode`,
help: `Leaves space for your thumb.`,
afterChange() {
fitSize();
2025-03-07 11:34:11 +01:00
},
2025-03-07 20:18:18 +01:00
disabled: () => false,
},
basic: {
default: false,
name: `Basic graphics`,
help: `Better performance on older devices.`,
afterChange:()=>{},
2025-03-07 20:18:18 +01:00
disabled: () => false,
},
pointerLock: {
default: false,
name: `Mouse pointer lock`,
help: `Locks and hides the mouse cursor.`,
afterChange:()=>{},
2025-03-07 20:18:18 +01:00
disabled: () => !gameCanvas.requestPointerLock,
},
easy: {
default: false,
name: `Kids mode`,
help: `Start future runs with "slower ball".`,
afterChange:()=>{},
2025-03-07 20:18:18 +01:00
disabled: () => false,
}, // Could not get the sharing to work without loading androidx and all the modern android things so for now i'll just disable sharing in the android app
record: {
default: false,
name: `Record gameplay videos`,
help: `Get a video of each level.`,
afterChange:()=>{},
2025-03-07 20:18:18 +01:00
disabled() {
return window.location.search.includes("isInWebView=true");
2025-03-07 11:34:11 +01:00
},
2025-03-07 20:18:18 +01:00
},
} as const satisfies {[k:string]:OptionDef};
2025-03-07 11:34:11 +01:00
export type OptionDef = {
2025-03-07 20:18:18 +01:00
default: boolean;
name: string;
help: string;
disabled: () => boolean;
afterChange: () => void;
2025-03-07 20:18:18 +01:00
};
export type OptionId = keyof typeof options ;