How rodriguezmldo/juego_espacial works
Project Type and Purpose
• This is a standalone 2D video-game written in Java (“juego_espacial”).
• It follows a classic game-loop architecture with distinct packages for game objects, rendering, input handling, UI screens, game states, and math utilities.
File Structure
• Top-level packages under src:
• main: entry point (main loop)
• interfaz: UI screens (menu, history, background loader)
• input: keyboard handler
• graphics: asset loader and rendering utilities
• states: game state management (e.g., menu state, play state)
• gameObjects: domain entities (asteroid, planet, player, laser, etc.)
• math: vector math utilities
• A parallel bin folder contains compiled classes; resources holds images, sounds, fonts, and data files.
• README confirms it’s a version-controlled Java video game for a programming class.
Main Components
a. Entry Point & Window
• Component: main.main → initializes Window and Game Loop
• Window (interfaz.Window) → game canvas and render context
b. Game Loop & State Manager
• Core loop drives update() and render() cycles
• states.GameState (abstract) & concrete state classes → encapsulate logic for menu, gameplay, pause, history screens
c. Input Module
• input.KeyBoard → polls key events and forwards them to current GameState or Player
d. Graphics/Asset Management
• graphics.Loader & graphics.Assets → load textures, sprites, fonts, and store in memory
e. Domain/Game Objects
• gameObjects.* → MovingObject, Player, Asteroid, Laser, Planet, Blackhole
• Constants define game-wide values
f. Math Module
• math.Vector2D → vector operations used by physics and movement
g. Resources
• File system abstraction or Resource Manager → reads from resources/gameData/data.txt and asset folders
h. External Dependencies
• Java runtime (AWT/Swing/Java2D)
Relationships and Interactions
• The Entry Point creates the Window and starts the Game Loop.
• On each frame:
• Input Module reads keyboard state → passes events to GameState.
• GameState.update() invokes entity logic in gameObjects using math.Vector2D.
• Graphics Module (Assets & Loader) supplies sprites to the Renderer.
• Renderer draws gameObjects, UI screens, and background onto Window canvas.
• GameState transitions (e.g., menu → play) happen via state manager.
Architectural Patterns and Design Principles
• Game Loop pattern for continuous update/render cycle.
• State pattern for menu/play/history screens.
• Separation of Concerns:
• Input handling isolated from game logic.
• Asset loading separated from rendering.
• Domain objects decoupled from UI code.
• Immutable constants and a utility math library for vector operations.