Refactor screen layout code, start player progress code

This commit is contained in:
2025-02-02 15:02:12 -08:00
parent 40ea1b909c
commit c095da2492
6 changed files with 111 additions and 31 deletions

View File

@ -91,6 +91,10 @@ export class Rect {
this.size = size;
}
offset(offset: Point) {
return new Rect(this.top.offset(offset), this.size);
}
contains(other: Point) {
return (other.x >= this.top.x && other.y >= this.top.y && other.x < this.top.x + this.size.w && other.y < this.top.y + this.size.h);
}
@ -186,5 +190,5 @@ export enum AlignX {
export enum AlignY {
Top = 0,
Middle = 1,
Right = 2,
Bottom = 2,
}

View File

@ -28,8 +28,10 @@ class Screen {
let active: Screen | undefined = undefined
export let desiredWidth = 384;
export let desiredHeight = 384;
// TODO: Move these to Game?
export let desiredWidth = 400;
export let desiredHeight = 400;
export function pollAndTouch(canvas: HTMLCanvasElement) {
let realWidth = canvas.offsetWidth;