Skip to content

A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D

A loading card that shows before the scripts arrive and lifts once the town is drawn

SandroMaglione10142443f2de
diff --git a/index.html b/index.html
index b054778..1cf79e1 100644
--- a/index.html
+++ b/index.html
@@ -8,9 +8,20 @@
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<link rel="stylesheet" href="/src/factory.css" />
<link rel="stylesheet" href="/src/phone.css" />
+ <!-- The loading card is styled here, not in the game's CSS, so it shows before anything else arrives. -->
+ <style>
+ #loading { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: #f0f2ec; color: #3d4943; font: 13px ui-monospace, "SF Mono", Menlo, monospace; transition: opacity 0.35s; }
+ #loading.done { opacity: 0; pointer-events: none; }
+ #loading b { font-size: 17px; letter-spacing: 0.04em; }
+ #loading .ink { width: 120px; height: 2px; background: #dfe3da; overflow: hidden; border-radius: 1px; }
+ #loading .ink::after { content: ""; display: block; width: 40%; height: 100%; background: #3d4943; animation: ink 1.1s ease-in-out infinite; }
+ @keyframes ink { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
+ @media (prefers-reduced-motion: reduce) { #loading .ink::after { animation: none; width: 100%; } }
+ </style>
</head>
<body>
<div id="app"></div>
+ <div id="loading" role="status"><b>Inkline Town</b><div class="ink"></div><span>drawing the town…</span></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
diff --git a/src/main.ts b/src/main.ts
index 84a71fe..366aae9 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -21,6 +21,14 @@ import { blankResources, simulate } from "./sim/index.ts"
/** Minutes of game time between autosaves. */
const AUTOSAVE_MINUTES = 2
+/** Fades the loading card out: once the town has drawn its first frame, or when it could not start. */
+const loaded = () => {
+ const card = document.getElementById("loading")
+ if (!card || card.classList.contains("done")) return
+ card.classList.add("done")
+ setTimeout(() => card.remove(), 400)
+}
+
const start = async () => {
const mount = document.getElementById("app")!
let persistence: Persistence = { save: () => "Not ready", load: () => "Not ready", shareFile: () => "" }
@@ -65,6 +73,7 @@ const start = async () => {
})
if (!made.ok) {
mount.textContent = `The town could not start: ${JSON.stringify(made.error)}`
+ loaded()
return
}
const runtime = made.value
@@ -173,15 +182,24 @@ const start = async () => {
settling = false
syncPage()
autosave()
+ // The first frame builds the town's meshes and shaders; the card lifts on the frame after it.
+ requestAnimationFrame(loaded)
},
onFailure: (failure) => {
mount.textContent =
failure.kind === "InvalidTickDelta" ? `Invalid frame delta: ${failure.deltaMS}` : "The town stopped after a system failure."
+ loaded()
}
})
- if (!loop.ok) mount.textContent = `Invalid fixed-loop option: ${loop.error.field}`
+ if (!loop.ok) {
+ mount.textContent = `Invalid fixed-loop option: ${loop.error.field}`
+ loaded()
+ }
}
-void start()
+start().catch((error: unknown) => {
+ document.getElementById("app")!.textContent = `The town could not start: ${error instanceof Error ? error.message : String(error)}`
+ loaded()
+})
if (import.meta.hot) import.meta.hot.accept(() => location.reload())