2024-10-24 11:32:31 +02:00
|
|
|
<script lang="ts">
|
|
|
|
import { onMount } from "svelte";
|
|
|
|
|
2024-10-24 19:27:33 +02:00
|
|
|
import Outside from "../board/Outside.svelte";
|
2024-10-24 11:32:31 +02:00
|
|
|
import Village from "../board/Village.svelte";
|
2024-11-07 11:18:49 +01:00
|
|
|
import Worldmap from "../board/Worldmap.svelte";
|
2024-10-24 19:27:33 +02:00
|
|
|
import gameTab from "../stores/gameTab";
|
|
|
|
import type { GameTab } from "../types";
|
2024-10-24 11:32:31 +02:00
|
|
|
import update from "../update";
|
|
|
|
import BuildingCreator from "./BuildingCreator.svelte";
|
2024-10-24 15:12:21 +02:00
|
|
|
import BuildingPanel from "./BuildingPanel.svelte";
|
2024-10-24 16:24:39 +02:00
|
|
|
import Navigation from "./Navigation.svelte";
|
2024-10-25 19:03:32 +02:00
|
|
|
import Resources from "./Resources.svelte";
|
|
|
|
import Units from "./Units.svelte";
|
2024-11-04 18:43:03 +01:00
|
|
|
import Victory from "./Victory.svelte";
|
2024-11-07 17:15:41 +01:00
|
|
|
import Quests from "./Quests.svelte";
|
2024-10-24 11:32:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
let frame: number;
|
|
|
|
|
|
|
|
function loop(timestamp: number) {
|
|
|
|
frame = requestAnimationFrame(loop);
|
|
|
|
update(timestamp);
|
|
|
|
}
|
|
|
|
frame = requestAnimationFrame(loop);
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
cancelAnimationFrame(frame);
|
|
|
|
}
|
|
|
|
});
|
2024-10-24 16:24:39 +02:00
|
|
|
|
|
|
|
function setTab(newTab: GameTab) {
|
|
|
|
gameTab.set(newTab);
|
|
|
|
}
|
2024-10-24 11:32:31 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<section class="hud">
|
|
|
|
<header>
|
2024-10-24 16:24:39 +02:00
|
|
|
<Navigation { setTab } />
|
2024-11-07 17:15:41 +01:00
|
|
|
<Resources />
|
2024-10-24 11:32:31 +02:00
|
|
|
</header>
|
2024-11-07 17:15:41 +01:00
|
|
|
<div class="side">
|
|
|
|
<Units />
|
|
|
|
<Quests />
|
|
|
|
</div>
|
2024-10-24 19:27:33 +02:00
|
|
|
<div class="board">
|
2024-10-24 16:24:39 +02:00
|
|
|
{ #if $gameTab === 'village' }
|
2024-10-24 11:32:31 +02:00
|
|
|
<Village />
|
2024-10-24 16:24:39 +02:00
|
|
|
{ :else if $gameTab === 'resources' }
|
|
|
|
<Outside />
|
2024-11-07 11:18:49 +01:00
|
|
|
{ :else if $gameTab === 'world' }
|
|
|
|
<Worldmap />
|
2024-10-24 16:24:39 +02:00
|
|
|
{ /if }
|
2024-10-24 11:32:31 +02:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<section class="overlay">
|
|
|
|
<BuildingCreator />
|
2024-10-24 15:12:21 +02:00
|
|
|
<BuildingPanel />
|
2024-11-04 18:43:03 +01:00
|
|
|
<Victory />
|
2024-10-24 11:32:31 +02:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<style>
|
2024-11-07 17:15:41 +01:00
|
|
|
.hud {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: 20vw 1fr 20vw;
|
|
|
|
grid-template-rows: 20vh 1fr;
|
|
|
|
height: 100vh;
|
|
|
|
width: 100vw;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hud header {
|
2024-10-24 19:27:33 +02:00
|
|
|
display: flex;
|
2024-11-07 17:15:41 +01:00
|
|
|
justify-content: center;
|
|
|
|
flex-direction: column;
|
|
|
|
grid-area: 1 / span 3;
|
2024-10-24 19:27:33 +02:00
|
|
|
}
|
|
|
|
|
2024-10-24 11:32:31 +02:00
|
|
|
.overlay {
|
|
|
|
left: 0;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
}
|
|
|
|
</style>
|