How xamdel/robo-royale works
Main Components
• Client-Side:
• Entry Point: index.html (with Vite configurations defined in vite.config.js for local development and client builds).
• Public Assets: Static assets (3D models, animations, audio clips) stored in public/assets.
• Game Logic / UI: Code under the src directory that includes:
· Core game loop logic (src/game.js, scene.js)
· Managers for models (src/ModelManager.js), audio (src/audio/AudioManager.js)
· HUD components (src/hud/*), mobile controls (src/mobileControls/*), and debug tools.
· Network management (src/network.js) responsible for communication with the server.
• Server-Side:
• Main Entry: server/index.js that bootstraps the server.
• Configuration: server/config/game-config.js for game parameters (tick rate, max players, etc.).
• Game Loop: server/game/game-loop.js handling real-time game state updates.
• Controllers: server/controllers/* that handle socket events (player actions, projectile dynamics, weapon handling).
• Data Models: server/models/* (player.js, projectile.js) for game entities.
• Services and Utilities: server/services such as validation logic.
Relationships and Interactions
• The client and server communicate over real-time protocols (e.g., Socket.IO).
• The client (through src/network.js) sends user input and game events to the server.
• The server game loop (server/game/game-loop.js) receives these events via controllers and updates models accordingly.
• Updated states are pushed back to clients to render updated scenes, HUD alerts, etc.
• The client is further decomposed into multiple subsystems:
• Rendering and Game Scene: The engine rendering the game scene using the models and environment settings.
• UI/HUD: User interface components (including mobile controls and HUD systems) that handle user feedback and in-game events.
• Audio: Synchronizing in-game sounds and environment audio, managed by AudioManager.
• The server structure encapsulates:
• Event Handling: Controllers that react to socket events (e.g., new player connections, firing weapons).
• Game Simulation: The core game loop that synchronizes game state.
• Data Validation and Modeling: Ensure game objects are processed correctly before updating state.
Architectural Patterns and Technologies
• Modular Architecture Partitioning: Clear separation between configuration, business logic (models, game loop), and network event handling (controllers).
• Real-Time Communication: Leveraging Socket.IO for client-server interaction.
• Static Asset Management: Vite is used on the client side for development and bundling, with a clear separation of static assets in the public folder.
• Separation of Concerns: Maintained by designating specific folders for controllers, services, models, etc., on the server side, and a similar modular breakdown on the client.
Additional Recommendations
• Every component (both on client and server) has clear, readable labels.
• Configuration files (like nodemon.json, package.json) in an “Infrastructure/Configuration” section to highlight environment dependency management if needed.