Initial commit — Djupet
Idle cult management game set in Malmö, Sweden. Manage Troende, Andakt, Dread, Hemlighet and Kaos while completing the Grand Ritual before investigators shut you down. Lovecraftian flavour, Henderson- tier chaos events, OSM/Leaflet map with dread spread markers across Rosengård, Värnhemstorget, Turning Torso and Øresundsbron. Vanilla TypeScript + Vite, no framework. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
41
src/main.ts
Normal file
41
src/main.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import './style.css';
|
||||
import { createState, tick, buyUpgrade } from './engine.ts';
|
||||
import { initUI, renderState } from './ui.ts';
|
||||
import { initMap, updateMap } from './map.ts';
|
||||
|
||||
let state = createState();
|
||||
let lastTime = 0;
|
||||
const TARGET_FPS = 30;
|
||||
const FRAME_MS = 1000 / TARGET_FPS;
|
||||
|
||||
function start(): void {
|
||||
const app = document.getElementById('app')!;
|
||||
|
||||
initUI(app,
|
||||
(id) => { state = buyUpgrade(state, id); renderState(state); },
|
||||
() => {
|
||||
state = createState();
|
||||
document.getElementById('overlay')!.classList.remove('visible');
|
||||
renderState(state);
|
||||
}
|
||||
);
|
||||
|
||||
initMap('map');
|
||||
renderState(state);
|
||||
|
||||
requestAnimationFrame(loop);
|
||||
}
|
||||
|
||||
function loop(now: number): void {
|
||||
if (now - lastTime >= FRAME_MS) {
|
||||
lastTime = now;
|
||||
if (state.phase === 'playing') {
|
||||
state = tick(state);
|
||||
renderState(state);
|
||||
updateMap(state.dread, state.areas);
|
||||
}
|
||||
}
|
||||
requestAnimationFrame(loop);
|
||||
}
|
||||
|
||||
start();
|
||||
Reference in New Issue
Block a user