feat: screen manager
This commit is contained in:
25
src/screens/contact-screen.ts
Normal file
25
src/screens/contact-screen.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { Screen, ScreenContext } from "../screen";
|
||||
import { HomeScreen } from "./home-screen";
|
||||
|
||||
export class ContactScreen implements Screen {
|
||||
renderTop(ctx: CanvasRenderingContext2D) {
|
||||
ctx.fillStyle = "#ffffff";
|
||||
ctx.font = "10px NDS10";
|
||||
ctx.textBaseline = "top";
|
||||
ctx.fillText("CONTACT", 1, 1);
|
||||
}
|
||||
|
||||
renderBottom(ctx: CanvasRenderingContext2D) {
|
||||
ctx.fillStyle = "#ffffff";
|
||||
ctx.font = "10px NDS10";
|
||||
ctx.textAlign = "left";
|
||||
ctx.textBaseline = "bottom";
|
||||
ctx.fillText("< Back", 1, 191);
|
||||
}
|
||||
|
||||
handleTouch(x: number, y: number, context: ScreenContext): void {
|
||||
if (x >= 0 && x <= 51 && y >= 178 && y <= 192) {
|
||||
context.navigate(new HomeScreen());
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/screens/home-screen.ts
Normal file
25
src/screens/home-screen.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { Screen, ScreenContext } from "../screen";
|
||||
import { ContactScreen } from "./contact-screen";
|
||||
|
||||
export class HomeScreen implements Screen {
|
||||
renderTop(ctx: CanvasRenderingContext2D) {
|
||||
ctx.fillStyle = "#ffffff";
|
||||
ctx.font = "10px NDS10";
|
||||
ctx.textBaseline = "top";
|
||||
ctx.fillText("HOME", 1, 1);
|
||||
}
|
||||
|
||||
renderBottom(ctx: CanvasRenderingContext2D) {
|
||||
ctx.fillStyle = "#ffffff";
|
||||
ctx.font = "10px NDS10";
|
||||
ctx.textAlign = "right";
|
||||
ctx.textBaseline = "bottom";
|
||||
ctx.fillText("Contact >", 255, 191);
|
||||
}
|
||||
|
||||
handleTouch(x: number, y: number, context: ScreenContext): void {
|
||||
if (x >= 205 && x <= 256 && y >= 178 && y <= 192) {
|
||||
context.navigate(new ContactScreen());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user