Files
dev.shadoll/src/js/main.js
T
sha 742a8154cf feat: add logo word with letter icons and physics
- Introduced a new logo system consisting of individual letter SVG icons for "shadolldev".
- Implemented LogoController to manage the floating logo word, including physics for movement and collisions with entities.
- Added LogoLetter class to handle individual letter behavior, including ejection and reattachment based on collisions.
- Integrated logo functionality into the main application flow, ensuring it initializes alongside the evolution system.
- Enhanced settings to control debug visibility for letter hit counts.
- Created styles for the logo letters, including animations for ejection and hit effects.
- Updated constants to define logo-related parameters such as letter size, speed, and collision properties.
2026-02-21 18:44:25 +02:00

57 lines
2.4 KiB
JavaScript

/**
* main.js
* Application entry point.
*
* Responsibilities:
* - Instantiate all controllers
* - Wire the settings button to the modal
* - Kick off the gradient and evolution system
*
* Keep this file thin — business logic lives in the controllers.
*/
import { GradientController } from './gradient.js';
import { ModalController } from './modal.js';
import { SettingsController } from './settings.js';
import { EvolutionController } from './evolution.js';
import { GuideController } from './guide.js';
import { LogoController } from './logoController.js';
import { DEFAULTS } from './constants.js';
// ── Initialise controllers ─────────────────────────────────
const gradient = new GradientController();
const modal = new ModalController();
const evolution = new EvolutionController();
const guide = new GuideController();
// SettingsController bridges UI → gradient + evolution
const settings = new SettingsController(gradient, evolution);
// ── Wire up settings button ────────────────────────────────
document.getElementById('settingsBtn').addEventListener('click', (e) => {
modal.open(/** @type {HTMLElement} */ (e.currentTarget));
});
// ── Wire up evolution guide ────────────────────────────────
guide.init(evolution);
// ── Boot gradient ──────────────────────────────────────────
gradient.init(DEFAULTS.GRADIENT_COLOR);
// Apply saved settings after gradient has set its defaults
settings.loadSaved();
// ── Boot logo + evolution ──────────────────────────────────
// Sequence: evolution.init() → reads localStorage (populates savedLogoState)
// logo.init(savedLogoState) → mounts letters, restores state
// setLogoController(logo) → arms per-tick calls
const logo = new LogoController();
const container = document.getElementById('evolutionContainer');
evolution.init(container)
.then(() => logo.init(container, evolution.savedLogoState))
.then(() => {
evolution.setLogoController(logo);
settings.setLogoController(logo);
});