first renderables
This commit is contained in:
parent
a6dd021494
commit
29d2006e61
5 changed files with 4934 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/node_modules
|
||||
4412
package-lock.json
generated
Normal file
4412
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
28
package.json
Normal file
28
package.json
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"name": "aether-shards",
|
||||
"version": "0.1.0",
|
||||
"description": "A tactical roguelike voxel game.",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "web-dev-server --node-resolve --watch --root-dir src",
|
||||
"test": "web-test-runner \"test/**/*.test.js\" --node-resolve",
|
||||
"test:watch": "web-test-runner \"test/**/*.test.js\" --node-resolve --watch"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://forge.mone.dev/mattmone/aether-shards.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@esm-bundle/chai": "^4.3.4-fix.0",
|
||||
"@web/test-runner": "^0.20.2",
|
||||
"@web/dev-server": "^0.4.6",
|
||||
"sinon": "^21.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"three": "^0.182.0"
|
||||
}
|
||||
}
|
||||
79
src/game-viewport.js
Normal file
79
src/game-viewport.js
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
import {
|
||||
LitElement,
|
||||
html,
|
||||
css,
|
||||
} from "https://cdn.jsdelivr.net/gh/lit/dist@3/core/lit-core.min.js";
|
||||
import * as THREE from "https://cdn.jsdelivr.net/npm/three@0.182.0/build/three.module.js";
|
||||
|
||||
// --- 1. Define the Game Viewport Component using Lit ---
|
||||
class GameViewport extends LitElement {
|
||||
static styles = css`
|
||||
:host {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
canvas {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
`;
|
||||
|
||||
firstUpdated() {
|
||||
// Initialize Three.js scene after the component renders
|
||||
this.initThreeJS();
|
||||
}
|
||||
|
||||
initThreeJS() {
|
||||
const container = this.shadowRoot.getElementById("canvas-container");
|
||||
const scene = new THREE.Scene();
|
||||
scene.background = new THREE.Color(0x0a0b10); // Void Black
|
||||
|
||||
const camera = new THREE.PerspectiveCamera(
|
||||
75,
|
||||
window.innerWidth / window.innerHeight,
|
||||
0.1,
|
||||
1000
|
||||
);
|
||||
const renderer = new THREE.WebGLRenderer({ antialias: true }); // Enable AA for smoother edges
|
||||
|
||||
// Set initial size
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
container.appendChild(renderer.domElement);
|
||||
|
||||
// Add a rotating Voxel (Cube)
|
||||
const geometry = new THREE.BoxGeometry();
|
||||
const material = new THREE.MeshBasicMaterial({
|
||||
color: 0x00f0ff,
|
||||
wireframe: true,
|
||||
});
|
||||
const cube = new THREE.Mesh(geometry, material);
|
||||
scene.add(cube);
|
||||
|
||||
camera.position.z = 5;
|
||||
|
||||
const animate = () => {
|
||||
requestAnimationFrame(animate);
|
||||
cube.rotation.x += 0.01;
|
||||
cube.rotation.y += 0.01;
|
||||
renderer.render(scene, camera);
|
||||
};
|
||||
animate();
|
||||
|
||||
// Handle Resize
|
||||
window.addEventListener("resize", () => {
|
||||
camera.aspect = window.innerWidth / window.innerHeight;
|
||||
camera.updateProjectionMatrix();
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return html` <div id="canvas-container"></div> `;
|
||||
}
|
||||
}
|
||||
|
||||
// Register the web component
|
||||
customElements.define("game-viewport", GameViewport);
|
||||
414
src/index.html
Normal file
414
src/index.html
Normal file
|
|
@ -0,0 +1,414 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Aether Shards - A tactical turn-based roguelike strategy game."
|
||||
/>
|
||||
<title>Aether Shards - Tactical Roguelike</title>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;700&family=Cinzel:wght@700&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
|
||||
<!-- IMPORT MAP: Defines module locations -->
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js",
|
||||
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/",
|
||||
"lit": "https://cdn.jsdelivr.net/gh/lit/dist@3/core/lit-core.min.js"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
:root {
|
||||
/* Palette Definition */
|
||||
--void-black: #0a0b10;
|
||||
--arcane-cyan: #00f0ff;
|
||||
--rust-orange: #ff6b35;
|
||||
--iron-grey: #4a5a6a;
|
||||
--gold-accent: #ffd700;
|
||||
|
||||
--voxel-depth: 6px;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: var(--void-black);
|
||||
font-family: "Chakra Petch", sans-serif;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* --- VISUAL LAYERS --- */
|
||||
|
||||
.bg-layer {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 0;
|
||||
background: radial-gradient(
|
||||
circle at 50% 30%,
|
||||
#1a1f35 0%,
|
||||
var(--void-black) 70%
|
||||
),
|
||||
linear-gradient(
|
||||
to bottom,
|
||||
transparent 80%,
|
||||
rgba(0, 240, 255, 0.05) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.particles {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1;
|
||||
opacity: 0.3;
|
||||
background-image: radial-gradient(
|
||||
var(--arcane-cyan) 1px,
|
||||
transparent 1px
|
||||
),
|
||||
radial-gradient(var(--rust-orange) 1px, transparent 1px);
|
||||
background-size: 40px 40px;
|
||||
animation: floatBackground 20s linear infinite;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* --- UI CONTAINER (Landing Page) --- */
|
||||
.ui-container {
|
||||
text-align: center;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 2rem;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 20px;
|
||||
transition: opacity 0.5s ease;
|
||||
}
|
||||
|
||||
/* Hidden state for transitions */
|
||||
.hidden {
|
||||
display: none !important;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
h1.title {
|
||||
font-family: "Cinzel", serif;
|
||||
font-size: clamp(3rem, 10vw, 6rem);
|
||||
margin: 0;
|
||||
line-height: 1.1;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.1em;
|
||||
color: #fff;
|
||||
text-shadow: 0px 4px 0px var(--iron-grey),
|
||||
0px 0px 20px var(--arcane-cyan);
|
||||
animation: titleFloat 4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: clamp(0.8rem, 3vw, 1.2rem);
|
||||
color: var(--arcane-cyan);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.3em;
|
||||
margin-bottom: 1rem;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.menu-btn {
|
||||
background: #2a3b4c;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 1.2rem 2rem;
|
||||
font-size: clamp(1rem, 4vw, 1.5rem);
|
||||
font-family: "Chakra Petch", sans-serif;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
transition: transform 0.1s;
|
||||
width: 100%;
|
||||
max-width: 350px;
|
||||
box-shadow: 0px var(--voxel-depth) 0px var(--iron-grey),
|
||||
0px calc(var(--voxel-depth) + 10px) 20px rgba(0, 0, 0, 0.5);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.menu-btn:hover {
|
||||
transform: translateY(-2px);
|
||||
background: #364a5e;
|
||||
box-shadow: 0px calc(var(--voxel-depth) + 2px) 0px var(--iron-grey),
|
||||
0px 0px 15px var(--arcane-cyan);
|
||||
color: var(--arcane-cyan);
|
||||
}
|
||||
|
||||
.menu-btn:active {
|
||||
transform: translateY(var(--voxel-depth));
|
||||
box-shadow: 0px 0px 0px var(--iron-grey);
|
||||
}
|
||||
|
||||
.btn-start {
|
||||
border-bottom: 4px solid var(--arcane-cyan);
|
||||
}
|
||||
.btn-load {
|
||||
border-bottom: 4px solid var(--gold-accent);
|
||||
}
|
||||
.btn-options {
|
||||
border-bottom: 4px solid var(--rust-orange);
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 0.7rem;
|
||||
color: #555;
|
||||
letter-spacing: 0.1em;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
/* --- LOADING SCREEN --- */
|
||||
#loading-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--void-black);
|
||||
z-index: 20;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.loader-cube {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
background-color: var(--arcane-cyan);
|
||||
animation: cubeSpin 1.5s infinite ease-in-out;
|
||||
box-shadow: 0 0 20px var(--arcane-cyan);
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
color: white;
|
||||
font-size: 1.2rem;
|
||||
letter-spacing: 0.2em;
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
|
||||
/* --- GAME VIEWPORT (3D Canvas) --- */
|
||||
game-viewport {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 5;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* --- ACCESSIBILITY & ANIMATION UTILS --- */
|
||||
@media (max-height: 600px) {
|
||||
.ui-container {
|
||||
gap: 1rem;
|
||||
}
|
||||
h1.title {
|
||||
font-size: 3rem;
|
||||
}
|
||||
.menu-btn {
|
||||
padding: 0.8rem 2rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
.particles {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
h1.title,
|
||||
.particles,
|
||||
.loader-cube {
|
||||
animation: none;
|
||||
}
|
||||
.menu-btn {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes titleFloat {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes floatBackground {
|
||||
0% {
|
||||
background-position: 0 0;
|
||||
}
|
||||
100% {
|
||||
background-position: 40px 40px;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes cubeSpin {
|
||||
0% {
|
||||
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
|
||||
}
|
||||
50% {
|
||||
transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
/* Screen Reader Only Class */
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
border: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Background Elements -->
|
||||
<div class="bg-layer" aria-hidden="true"></div>
|
||||
<div class="particles" aria-hidden="true"></div>
|
||||
|
||||
<!-- Live Region for A11y Announcements -->
|
||||
<div id="a11y-announcer" class="sr-only" aria-live="assertive"></div>
|
||||
|
||||
<!-- MAIN MENU UI -->
|
||||
<div id="landing-ui" class="ui-container">
|
||||
<div>
|
||||
<h1 class="title">Aether<br />Shards</h1>
|
||||
<div class="subtitle">The Great Stillness Awaits</div>
|
||||
</div>
|
||||
|
||||
<nav aria-label="Main Menu">
|
||||
<button id="btn-start" class="menu-btn btn-start">New Descent</button>
|
||||
<button class="menu-btn btn-load">Continue</button>
|
||||
<button class="menu-btn btn-options">Guild Archives</button>
|
||||
</nav>
|
||||
|
||||
<div class="footer">PRE-ALPHA BUILD v0.1 | GENERATED BY GEMINI</div>
|
||||
</div>
|
||||
|
||||
<!-- LOADING SCREEN (Hidden by default) -->
|
||||
<div id="loading-overlay" class="hidden" role="alert" aria-busy="true">
|
||||
<div class="loader-cube"></div>
|
||||
<div class="loading-text" id="loading-message">
|
||||
INITIALIZING VOXEL ENGINE...
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- GAME VIEWPORT CONTAINER -->
|
||||
<game-viewport class="hidden" aria-label="Game World"></game-viewport>
|
||||
|
||||
<!-- GAME LOGIC (MODULE SCRIPT) -->
|
||||
<script type="module">
|
||||
// --- 2. Accessibility Helper ---
|
||||
function announce(message) {
|
||||
const announcer = document.getElementById("a11y-announcer");
|
||||
announcer.textContent = message;
|
||||
}
|
||||
|
||||
// --- 3. New Descent Logic (Using Dynamic Import) ---
|
||||
// We attach listener inside the module script because module scope is local
|
||||
document
|
||||
.getElementById("btn-start")
|
||||
.addEventListener("click", startNewDescent);
|
||||
|
||||
async function startNewDescent() {
|
||||
// A. Update State & UI
|
||||
const landingUI = document.getElementById("landing-ui");
|
||||
const loader = document.getElementById("loading-overlay");
|
||||
const loadingMsg = document.getElementById("loading-message");
|
||||
|
||||
landingUI.classList.add("hidden");
|
||||
loader.classList.remove("hidden");
|
||||
|
||||
// B. Accessibility Updates
|
||||
announce("Starting new game. Loading game engine.");
|
||||
loadingMsg.textContent = "LOADING GAME COMPONENT...";
|
||||
|
||||
// C. Lazy Load logic (Components registered via import above)
|
||||
try {
|
||||
// Simulate loading time
|
||||
setTimeout(() => {
|
||||
loadingMsg.textContent = "GENERATING VOXEL GRID...";
|
||||
initializeGameWorld();
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
console.error("Failed to load game:", error);
|
||||
loadingMsg.textContent = "ERROR LOADING ENGINE. PLEASE REFRESH.";
|
||||
announce("Error loading game engine. Please refresh.");
|
||||
}
|
||||
}
|
||||
|
||||
// --- 4. Game Initialization ---
|
||||
async function initializeGameWorld() {
|
||||
const loader = document.getElementById("loading-overlay");
|
||||
const gameViewport = document.querySelector("game-viewport");
|
||||
await import("./game-viewport.js");
|
||||
|
||||
// D. Transition to Game
|
||||
loader.classList.add("hidden");
|
||||
gameViewport.classList.remove("hidden");
|
||||
announce("Game loaded. Tactical grid active.");
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue