2024-10-24 11:32:31 +02:00
|
|
|
<script lang="ts">
|
|
|
|
import { onMount } from "svelte";
|
|
|
|
|
|
|
|
import Village from "../board/Village.svelte";
|
|
|
|
import update from "../update";
|
|
|
|
import BuildingCreator from "./BuildingCreator.svelte";
|
|
|
|
import Resources from "./Resources.svelte";
|
2024-10-24 15:12:21 +02:00
|
|
|
import BuildingPanel from "./BuildingPanel.svelte";
|
2024-10-24 16:24:39 +02:00
|
|
|
import Outside from "../board/Outside.svelte";
|
|
|
|
import Navigation from "./Navigation.svelte";
|
|
|
|
import type { GameTab } from "../types";
|
|
|
|
import gameTab from "../stores/gameTab";
|
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>
|
|
|
|
<Resources />
|
2024-10-24 16:24:39 +02:00
|
|
|
<Navigation { setTab } />
|
2024-10-24 11:32:31 +02:00
|
|
|
</header>
|
2024-10-24 16:24:39 +02:00
|
|
|
<div class="">
|
|
|
|
{ #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 />
|
|
|
|
{ /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-10-24 11:32:31 +02:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.overlay {
|
|
|
|
left: 0;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
}
|
|
|
|
</style>
|