A 2D physics-based projectile game inspired by Angry Birds, built in Java with libGDX and Box2D.
This version is a polished desktop demo with stable physics, a slingshot launch mechanic, level selection, trajectory visualization, and a lightweight UI built directly with libGDX drawing APIs.
- Fixed-step Box2D physics for more stable and predictable gameplay.
- Gravity disabled at level load and enabled instantly on the first shot.
- Trajectory tracker that shows:
- a dotted aim / prediction line while dragging
- a dotted flight trail after launch
- Texture caching for generated
Pixmaptextures to reduce allocation churn. - How To Play overlays in both the menu and level select screens.
- All levels unlocked for demo purposes.
- A playful re-theme where the visible projectile looks like a pig and the targets look like birds.
- JDK 17 or newer
- No separate Gradle installation is required — the project includes the Gradle Wrapper
From the project root:
.\gradlew.bat clean build
.\gradlew.bat runIf you prefer a Unix-like shell, use:
./gradlew clean build
./gradlew runENTER/SPACE— start the gameL— open level selectH— open How To Play overlayESC— exit
1…5— choose a levelH— open How To Play overlayB/ESC— return to the menu
- Click and drag the projectile on the slingshot to aim
- Release to launch
R— restart the current levelD— toggle Box2D debug viewESC— return to level select
src/main/java/com/angrybirds/
├── AngryBirdsGame.java
├── DesktopLauncher.java
├── entities/
│ ├── Bird.java
│ ├── Block.java
│ ├── Pig.java
│ └── Slingshot.java
├── game/
│ └── GameInputProcessor.java
├── graphics/
│ ├── TextureCache.java
│ └── TrajectoryTracker.java
├── physics/
│ └── PhysicsWorld.java
└── screens/
├── GameScreen.java
├── LevelSelectScreen.java
└── MenuScreen.java
AngryBirdsGame.java— app entry point and screen switchingPhysicsWorld.java— Box2D wrapper, fixed-step update loop, gravity controlGameScreen.java— main gameplay loop, level setup, damage handling, HUDSlingshot.java— pull / release launch mechanicTrajectoryTracker.java— dotted prediction and flight trail renderingTextureCache.java— reuse generated textures instead of recreating themMenuScreen.javaandLevelSelectScreen.java— menu UI and instructions overlays
- A level is loaded with a slingshot, structures, and targets.
- Gravity is disabled so the scene stays stable before the first shot.
- The player drags the projectile back to aim.
- A dotted prediction line is shown while aiming.
- On release, the projectile is launched and gravity is enabled immediately.
- The flight trail records the bird path.
- Collisions apply damage using Box2D contact impulses.
- Clearing all targets wins the level.
The game uses Box2D for the world simulation. The important implementation details are:
- Fixed-step accumulation in
PhysicsWorld.update(float delta)- makes the simulation less sensitive to fluctuating frame rates
- clamps large frame spikes so the physics does not overstep badly
- Collision listener in
GameScreen- uses
postSolve()contact impulses to decide whether a hit should deal damage
- uses
- Entity metadata
- Box2D bodies store their owning game object in
userDataso collisions can be mapped back toBird,Pig, andBlock
- Box2D bodies store their owning game object in
- The project uses
SpriteBatchfor textures andShapeRendererfor simple shapes/UI. - Generated textures are cached in
TextureCacheso repeated objects do not create newTextureinstances every time. - The game disposes cached textures on shutdown to avoid memory leaks.
GlyphLayoutis used for measuring text width safely, instead of mutating font caches.
The assets/ folder contains the game art used by the desktop build:
background.jpglevel_background_1.png…level_background_5.png- imported art folders under
_imported_backgrounds/
If you want to use piggy.webp as the main pig artwork, it is usually easiest to convert it to PNG and load it as a normal libGDX Texture.
- Add sound effects for launch, hits, and level completion
- Externalize level layouts into JSON files
- Improve the aim preview into a full ballistic prediction arc
- Add persistent level progression instead of always unlocking every level
- Replace runtime-generated shapes with prebuilt art assets or a texture atlas
- Add automated tests for physics stepping and entity behavior
- Built with libGDX and Box2D
- Designed as a student project / demo build
No explicit license is provided in the repository. If you plan to share or publish the project, add a license file first.