A Java desktop game inspired by The World's Hardest Game, built with AWT/Swing-style rendering, keyboard input, collision detection, enemy movement, collectibles, levels, and skill-based gameplay.
This project began as an early college programming assignment and was overhauled into a cleaner game development and object-oriented programming showcase.
- Player movement using keyboard input
- Moving enemy obstacles with horizontal and vertical patrol patterns
- Spinning rectangular hazards
- Collision detection between the player and enemies
- Accurate collision detection for spinning hazards using rotated shape intersection
- Respawn behavior after collisions
- Death tracking instead of negative score
- Timer tracking elapsed play time
- Coins/collectibles required before completing each level
- Three playable levels with increasing difficulty
- Start screen, level-complete screen, and campaign-complete screen
- Restart current level with
R - Restart full game with
N - Cleaner HUD showing level, deaths, total deaths, time, and coins
- Java
- AWT / Swing-style desktop rendering
- Object-Oriented Programming
- Collision detection
- Game loop logic
Download the runnable JAR from the latest release.
Navigate the red player square from the start zone to the goal zone while avoiding blue enemies and pink spinning hazards. Each level requires collecting all coins before the goal can be completed.
Controls:
Arrow Keys: Move
Enter: Start / Next Level
R: Restart Current Level
N: Restart Full Game-
Prerequisites: Ensure Java is installed.
java -version
-
Build and run the project:
./run.sh
The run script creates a packaged application automatically. You can also build and launch it separately:
./build.sh
java -jar dist/worlds-hardest-game.jarRun the dependency-free collision and boundary smoke tests:
./test.shThe GitHub Actions workflow runs these tests, builds the JAR, and uploads it as a workflow artifact on every push and pull request.
Version 1.0.1 is available from GitHub Releases and includes:
worlds-hardest-game.jar
After downloading the release asset, launch it with:
java -jar worlds-hardest-game.jarworlds-hardest-game/
├── src/
│ └── game/
│ ├── Enemy.java
│ ├── Game.java
│ ├── IntersectionDetectable.java
│ ├── Player.java
│ ├── SpinningRectangle.java
│ └── WorldsHardestGame.java
├── src/test/java/game/
│ └── CollisionSmokeTest.java
├── .github/workflows/
│ └── build.yml
├── build.sh
├── run.sh
├── test.sh
├── README.md
└── .gitignoreControls the main game setup, game loop, rendering, levels, HUD, win state, timer, score/death tracking, enemies, collectibles, and keyboard input.
Represents the controllable player square, including movement flags, boundary checks, respawn behavior, and drawing logic.
Represents moving circular hazards that patrol horizontally or vertically and use circle-rectangle collision detection against the player.
Represents rotating rectangular hazards and uses shape-based collision detection so the player only dies when touching the visible rotating rectangle.
Handles the Java window/canvas setup and double-buffered drawing.
- How to build a Java desktop game
- How game loops update and repaint the screen
- How to handle keyboard input in Java
- How collision detection works with circles, rectangles, and rotated shapes
- How to structure levels and game state
- How object-oriented design can model players, enemies, hazards, and gameplay systems
- How early projects can be refactored into cleaner, more maintainable code
- Add more levels with different maze layouts
- Add wall obstacles instead of only open-board hazards
- Add a level-select screen
- Add sound effects and background music
- Add persistent best times/death counts
- Add a short gameplay GIF
- Improve visual polish with custom sprites or smoother animations
