A multi-level 2D action game built with Java and the City Physics Engine.
Robot City is a side-scrolling platformer that demonstrates advanced Object-Oriented Programming (OOP) concepts and real-time physics simulation.
Developed as coursework for City, University of London, this project implements a game engine using the university's proprietary City Physics Engine (a customized wrapper for JBox2D). The player controls a character who must navigate hostile environments, combat robotic enemies, and solve physics-based puzzles to progress through three distinct levels.
- Rigid Body Simulation: All movement and collisions are governed by a physics engine, allowing for realistic momentum and object interactions.
- Projectile Combat: A custom shooting mechanic (
DestroyProjectile) that calculates trajectory based on mouse input to destroy enemies. - Dynamic Collision Handling: Specialized listeners (
KillPlayer,PlayerCollision) manage complex interactions between the player, enemies, and environment.
- Enemy Variety:
- Ground Units: Patrol platforms and deal contact damage (
RobotSmall). - Flying Drones: Aerial enemies (
RobotFlying) that track player movement. - Heavy Units: Larger, tougher enemies (
RobotBig) acting as obstacles.
- Ground Units: Patrol platforms and deal contact damage (
- Level Progression: A key-and-door system requires players to explore the map to unlock the path to the next level.
- Resource Management: Collect coins for score and manage health (displayed via a custom HUD).
- Game Loop: Custom timer-based game loop managing physics steps and rendering.
- View Management: A
GameViewclass that overlays a custom HUD (Heads-Up Display) for health and score tracking onto the physics world. - Audio Integration: Integrated sound effects for actions like shooting, jumping, and collecting items.
- Language: Java (JDK 8+)
- Physics Engine: City Engine (Proprietary JBox2D wrapper provided by City, University of London)
- Graphics: Java Swing & AWT (Custom painting)
- Concepts: Inheritance, Polymorphism, Event Handling, Finite State Machines
src/game/
├── Game.java # Main entry point; manages level switching and window
├── GameLevel.java # Abstract base class handling common level logic
├── Level1.java # Concrete implementation of the first level
├── Level2.java # Intermediate level with increased difficulty
├── Level3.java # Final level implementation
├── Player.java # Main character controller with physics attributes
├── PlayerController.java # Keyboard input handling (WASD/Arrow keys)
├── GameView.java # Renders the background, character, and UI overlays
├── DestroyProjectile.java # Logic for projectile physics and impact
├── Coins.java # Collectible item logic
├── Key.java # Quest item logic for level progression
└── Enemies/
├── RobotSmall.java # Basic enemy AI
├── RobotBig.java # Heavy enemy logic
└── RobotFlying.java # Flying enemy logic
- Java Development Kit (JDK): Version 8 or higher.
- CityEngine Library: You must add the
city-engine.jar(andjbox2d.jar) to your project's classpath.
- Clone the repository:
git clone [https://github.com/YusufQuresh1/Robot-City-Platformer.git](https://github.com/YusufQuresh1/Robot-City-Platformer.git)
- Import into IDE: Open the project in IntelliJ IDEA, Eclipse, or VS Code.
- Configure Libraries: Add the CityEngine
.jarfiles to your project dependencies/build path. - Run: Execute
Game.javaas the main class.
| Key | Action |
|---|---|
| W / Space | Jump |
| A | Move Left |
| D | Move Right |
| Mouse Click | Aim & Shoot Projectile |
Yusuf Qureshi Connect with me on LinkedIn to discuss this project further.