Game states and main menu

This commit is contained in:
2026-02-25 22:58:36 -03:00
parent 4862bef3f7
commit 28f0422771
8 changed files with 143 additions and 84 deletions
+38
View File
@@ -0,0 +1,38 @@
import { Entity } from "$/common/ecs/mod.ts";
import { Position } from "$/common/components/position.ts";
import { ClientWorld } from "./client_world.ts";
import { Tilemap } from "./components/tilemap.ts";
import { AssetManager } from "./assets.ts";
import { create_player } from "./player.ts";
import { UIButton } from "./components/ui_components.ts";
import { open_about } from "./about.ts";
export function start_game(world: ClientWorld) {
world.state = "game";
world.clear_entities();
const tilemap = new Entity("backgroundtiles");
tilemap.add(
new Tilemap(
AssetManager.instance.get("bworld:roguelike"),
16,
[],
2,
1,
),
);
world.add_entity(tilemap);
create_player(world);
// UI !
const unpause_button = new Entity("unpausebutton");
unpause_button.add(new Position(world.canvas.width / 2 - 150, world.canvas.height / 2 - 80));
unpause_button.add(new UIButton("Unpause", 320, 64, () => world.state = "paused"));
world.add_entity(unpause_button);
const about_button = new Entity("aboutbutton");
about_button.add(new Position(world.canvas.width / 2 - 150, world.canvas.height / 2 + 80));
about_button.add(new UIButton("About", 320, 64, () => open_about()));
world.add_entity(about_button);
}