PlayerVsPlayer is a real-time 2D competitive desktop game built in Java 21 using a custom game loop and object-oriented architecture. The game supports two human players competing simultaneously on the same system, with randomly spawning items that affect gameplay dynamics.
The project is built using Gradle and distributed as a runnable JAR for easy execution.
- Local 2-player competitive match
- Real-time character movement
- Projectile-based combat
- Randomly spawning power-up items
- Collision detection between players, items, and projectiles
- Structured game state management
The gameplay is designed around responsiveness and fairness, requiring careful synchronization of input handling and rendering updates.
The system follows a modular object-oriented structure.
- Custom update-render cycle
- Controlled frame updates for smooth gameplay
- Separation of update logic and drawing logic
- Base entity abstraction
- Player character entities
- Projectile entities
- Randomly spawning item entities
- Bounding-box collision detection
- Projectile impact handling
- Item pickup logic
- Event-driven keyboard listeners
- Simultaneous two-player input support
- Non-blocking input processing
- Real-time 2D rendering using Java graphics APIs
- Frame redraw management
- Object-layered drawing pipeline
- Java 21
- Gradle build system
- IntelliJ IDEA (development)
- Object-Oriented Programming
- Event-Driven Architecture
Using the Gradle wrapper (recommended):
./gradlew buildOn Windows:
gradlew.bat buildThe compiled JAR will be generated in:
build/libs/
java -jar build/libs/PlayerVsPlayer.jar./gradlew runOpen the project in IntelliJ and run the main launcher class.
| Action | Player 1 | Player 2 |
|---|---|---|
| Move Up | W | ↑ |
| Move Down | S | ↓ |
| Move Left | A | ← |
| Move Right | D | → |
| Shoot | Shift | Ctrl |
- Managing simultaneous two-player input
- Designing deterministic collision behavior
- Synchronizing update and render cycles
- Implementing randomized item spawning logic
- Structuring entity abstraction for scalability
- Scoring system
- Map variations
- Sound engine integration
- Additional power-up mechanics
- Networked multiplayer
- Real-time systems design
- Custom game loop implementation
- Strong object-oriented architecture
- Gradle-based Java project structure
- Multi-entity interaction handling