aether-shards/src/ui/game-viewport.js

36 lines
771 B
JavaScript
Raw Normal View History

2025-12-16 23:52:58 +00:00
import { LitElement, html, css } from "lit";
import { gameStateManager } from "../core/GameStateManager.js";
import { GameLoop } from "../core/GameLoop.js";
2025-12-16 23:52:58 +00:00
export class GameViewport extends LitElement {
2025-12-16 23:14:39 +00:00
static styles = css`
:host {
display: block;
width: 100%;
height: 100%;
overflow: hidden;
}
2025-12-16 23:52:58 +00:00
#canvas-container {
2025-12-16 23:14:39 +00:00
width: 100%;
height: 100%;
}
`;
2025-12-16 23:52:58 +00:00
constructor() {
super();
}
2025-12-17 19:26:42 +00:00
async firstUpdated() {
2025-12-16 23:14:39 +00:00
const container = this.shadowRoot.getElementById("canvas-container");
const loop = new GameLoop();
loop.init(container);
gameStateManager.setGameLoop(loop);
2025-12-16 23:14:39 +00:00
}
render() {
2025-12-16 23:52:58 +00:00
return html`<div id="canvas-container"></div>`;
2025-12-16 23:14:39 +00:00
}
}
customElements.define("game-viewport", GameViewport);