# programmingsis/jogo-de-pong architecture

> Architecture diagram of the GitHub repository programmingsis/jogo-de-pong, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/programmingsis/jogo-de-pong
- Repository: https://github.com/programmingsis/jogo-de-pong

## Overview

##### Project type and purpose
- This is a local, standalone Java game—a simple Pong clone—built with object-oriented principles.
- Players control paddles via keyboard; the game engine detects collisions, updates scores, and renders graphics.
- A precompiled library (GameLib.jar) provides base classes, and the student implements Ball, Player, and Score classes.

##### File structure
- Top-level:
- README.md – describes the game and assignment.
- build/ – likely holds compiled artifacts.
- lib/ – contains GameLib.jar and its generated Javadoc.
- src/ – your source files and Makefile.
- src/ contains: Ball.java, Player.java, Score.java, plus a Makefile for compilation.
- lib/GameLib.jar holds core framework classes (Pong, Wall, etc.) that your code extends or uses.

##### README for additional insights
- The README highlights modularity and OOP design: each class has a single responsibility (ball movement, player input, scoring).
- There’s no network layer or database—everything runs in one process.

##### Main components and their interactions
a. Game Launcher / Main Loop
- Starts the game, enters the render–update loop, and terminates when the user exits.
b. Input Controller
- Listens for keyboard events, maps keys to Player actions (move up/down).
c. Game Model (Entities)
- Ball: position, velocity, collision logic.
- Player (Paddle): position, movement bounds.
- Score: maintains and updates each player’s points.
- Wall: boundary collision (in GameLib).
d. GameLib (External Library)
- Provides base classes (Pong, Wall, utility methods) that your entities use or subclass.
e. Renderer / View
- Draws the Ball, Paddles, Scoreboard to the screen each frame.

Relationships & Data Flow
- Input Controller → Model: on key press, calls Player.move().
- Main Loop → Model: updates Ball.move(), checks collisions.
- Model → Score: on collision behind paddle, Score.increment().
- Renderer → Display: issues graphics calls.

##### Architectural patterns & design principles
- Model–View–Controller (MVC) style separation:
- Model: Ball, Player, Score, Wall.
- View: rendering subsystem (Graphics2D or similar).
- Controller: keyboard input handler.
- Single Responsibility Principle: each class has one reason to change.
- Dependency on external library (GameLib.jar) for common game abstractions.

##### Technologies and tools
- Java SE (AWT/Swing or custom GameLib rendering).
- Makefile-driven build to compile .java into .class files under build/.
- GameLib.jar as a provided dependency.

##### Final checklist
- [ ] Clearly labeled components (MainLoop, InputController, Ball, Player, Score, GameLib.jar, Renderer)
- [ ] Annotations for collision handling and scoring events
- [ ] Grouping or layering that shows MVC separation

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Controller Layer"
        IC["InputController"]:::controller
        ML["MainLoop / GameEngine"]:::engine
    end

    subgraph "Model Layer"
        Ball["Ball"]:::model
        Player["Player"]:::model
        Score["Score"]:::model
    end

    subgraph "View Layer"
        Renderer["Renderer / View"]:::view
    end

    subgraph "External Library"
        GameLib["GameLib.jar"]:::external
    end

    subgraph "Build & Docs"
        Build["build/"]:::infra
        Makefile["Makefile"]:::infra
        Javadoc["javadoc/"]:::infra
        README["README.md"]:::infra
    end

    IC -->|"keyPressed → Player.move()"| Player
    ML -->|"update() → Ball.move()"| Ball
    Ball -->|"collision behind paddle → Score.increment()"| Score
    ML -->|"draw() → Renderer.draw(Model)"| Renderer
    Renderer -->|"uses render utilities"| GameLib
    Player -->|"extends Paddle class"| GameLib
    Ball -->|"extends Ball class"| GameLib
    Score -->|"uses scoring API"| GameLib
    ML -->|"core loop implementation"| GameLib

    click ML "https://github.com/programmingsis/jogo-de-pong/blob/master/lib/GameLib.jar"
    click IC "https://github.com/programmingsis/jogo-de-pong/blob/master/src/Player.java"
    click Ball "https://github.com/programmingsis/jogo-de-pong/blob/master/src/Ball.java"
    click Player "https://github.com/programmingsis/jogo-de-pong/blob/master/src/Player.java"
    click Score "https://github.com/programmingsis/jogo-de-pong/blob/master/src/Score.java"
    click GameLib "https://github.com/programmingsis/jogo-de-pong/blob/master/lib/GameLib.jar"
    click Renderer "https://github.com/programmingsis/jogo-de-pong/blob/master/lib/GameLib.jar"
    click Build "https://github.com/programmingsis/jogo-de-pong/tree/master/build/"
    click Makefile "https://github.com/programmingsis/jogo-de-pong/tree/master/src/Makefile"
    click Javadoc "https://github.com/programmingsis/jogo-de-pong/tree/master/lib/javadoc/"
    click README "https://github.com/programmingsis/jogo-de-pong/blob/master/README.md"

    classDef controller fill:#9f6,stroke:#333,stroke-width:1px
    classDef engine fill:#afa,stroke:#333,stroke-width:1px
    classDef model fill:#6cf,stroke:#333,stroke-width:1px
    classDef view fill:#f96,stroke:#333,stroke-width:1px
    classDef external fill:#ccc,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef infra fill:#fc9,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
```
