Pac-Man
Arcade-faithful clone with per-ghost personality AI and A* pathfinding
Overview
A fully playable Pac-Man clone built from scratch in Java using JOGL for hardware-accelerated 2D rendering, with faithful ghost AI implementing the exact scatter/chase/frightened finite state machine from the original arcade's Pac-Man Dossier. Features A* pathfinding for ghost navigation, per-ghost personality targeting algorithms (Blinky, Pinky, Inky, Clyde), TMX-format level loading, and corner-cutting collision for responsive controls.
Code Highlights
@Override
protected void AI() {
int tx = target.getX(), ty = target.getY();
int td = target.getDirection();
// 2-tile offset in Pac-Man's facing direction
if (td == 2) { tx += Math.min(2, world.getWidth() - 2 - tx); }
else if (td == 1) { tx -= Math.min(2, tx - 1); }
else if (td == 3) { ty -= Math.min(2, ty - 1); }
else if (td == 4) { ty += Math.min(2, world.getHeight() - 2 - ty); }
// Vector from Blinky to offset, doubled
int v_x = blinky.getX() + (tx - blinky.getX()) * 2;
int v_y = blinky.getY() + (ty - blinky.getY()) * 2;
path = solver.solveMaze(x, y, v_x, v_y);
}Highlights
- Implemented authentic Pac-Man ghost AI with per-ghost personality targeting algorithms (direct pursuit, 4-tile ambush, vector-doubling flanking, distance-threshold retreat) faithfully matching the original arcade's documented behavior
- Built A* pathfinding from scratch with Manhattan-distance heuristic, priority-queue expansion, and pre-computed maze grid for real-time navigation of 4 ghosts at 60 FPS
- Designed a complete game engine architecture with entity hierarchy, time-driven game loop, finite state machine, dual-coordinate movement system, and data-driven TMX level loading
- Engineered responsive controls via corner-cutting collision -- a per-corner AABB nudge system replicating the original Pac-Man's slide-around-corners feel
Related Projects
Monte Carlo Path Tracer + Spline Engine
Physically-based renderer with importance sampling and a functorial spline animation system
Physically-based Monte Carlo path tracer implementing the rendering equation with importance sampling, Russian roulette termination, explicit direct light sampling via solid-angle cone sampling, and three BxDF models (Lambertian, specular with Fresnel, Oren-Nayar rough diffuse)
3D Rendering Engine with Shadow Mapping
Custom OpenGL engine comparing four shadow mapping algorithms with runtime switching
Implemented and compared four shadow mapping algorithms (default, PCF, VSM with Gaussian blur, CSM with per-cascade resolution) in a single engine with runtime switching
Tossing Balls
High school graduation project — 2D physics puzzle game with Box2D integration and data-driven level loading
High school graduation project (age 17) — built a complete 2D physics game engine from scratch in C++ with a custom entity system, polymorphic animation framework, Box2D physics integration, and data-driven level loading from XML