How lwrcs/turnarchist works
Main Components
• Game Engine / Main Loop: The heart of the project is the game loop (game.ts/game.js) that orchestrates all other subsystems.
• Input Manager: Managed by input.ts which processes keyboard/mouse events.
• Renderer / Drawable: Based on files like drawable.ts and the HTML files (index.html, help.html), the game renders visual elements on a canvas or via the DOM.
• Entity Component System: Entities include players, enemies (enemy folder), items (item folder), projectiles (projectile folder), and weapons (weapon folder). Each has its own module, making them clear “component” blocks.
• World / Level Manager: Modules like level.ts, levelConstants.ts, levelGenerator.ts, and map.ts represent the game world structure.
• Tile & Map System: The “tile” modules (both in src and js) indicate the breakdown of the game grid – different tile types like floor, wall, door, etc.
• Particle & Effects System: Files in the “particle” subdirectories handle visual effects such as death particles, dash particles, and text particles.
• Audio / Sound System: The sound.ts file and the “res/SFX” folder point to a dedicated sound and audio management subsystem.
• Resource Manager: Resources in “res” (music, sound effects, images if present) are likely managed/loaded by specific utility functions.
• Build/Deployment Tools: The webpack config, TypeScript configuration, and shell scripts (e.g., dropbox_update.sh) represent the build and deployment pipeline.
Relationships and Interactions
• The Game Engine (main loop) is at the center. It imports and calls the Input Manager to handle player actions.
• The Input Manager feeds directly into the Game Engine to update game states.
• The Entity Manager contains player, enemy, and item components. They interact with the World Manager which is defined by level and map modules.
• The Audio System is triggered by game events (collisions, attacks, item pickups), and this flows from the Game Engine to the Sound Manager.
• The Particle System is used for visual feedback and effects during events (enemy death, spell effects, etc.).
• The Build tools ensure that TypeScript source in “src” is correctly transpiled into the “js” distribution used by the HTML files.
Architectural Patterns and Design Principles
• Separation of Concerns: The project cleanly distinguishes between game logic, rendering, input handling, and resource management.
• Modular Design: With distinct folders for enemy, item, tile, particle, and weapon, the architecture is broken into well-defined, loosely coupled modules.
What
– Game Engine / Main Loop
– Input Manager
– Renderer / Drawable Layer
– Entity Manager (with subcomponents: Player, Enemy, Items, Projectiles, Weapons)
– World / Level Manager and Map/Tile System
– Particle/Effects System
– Audio/Sound System
– Resource/Asset Manager
– Build/Deployment Pipeline (as a supporting component)
• Simple annotations that indicate important actions (e.g., “handles keyboard events”, “renders frame”, “loads assets”).