Swim.io

A fish-eat-fish game inspired by agar.io with responsive controls, collision detection, and growth mechanics in a vibrant underwater environment.

JavaJavaFX

The Problem

I wanted to build a fun, polished arcade game that exercised core game development skills — physics, collision detection, state machines, and rendering optimization — in a single cohesive project.

The Solution

I built Swim.io as a single-player fish-eat-fish game where the player's fish grows by consuming smaller fish while avoiding larger predators.

  • Collision detection — Bounding circle checks with size-based resolution (bigger fish eats smaller fish).
  • Growth mechanics — Fish size increases proportionally to consumed prey, unlocking new areas of the map.
  • Responsive controls — Smooth mouse/keyboard input with momentum-based movement that feels fluid.
  • AI fish behavior — Enemy fish follow simple steering behaviors (seek, flee, wander) scaled by their size relative to the player.
  • Vibrant underwater rendering — Layered backgrounds with parallax scrolling for depth perception.

What Went Wrong

The initial collision detection checked every fish against every other fish (O(n^2)), which caused frame drops when the screen had 50+ fish.

The fix: I implemented spatial partitioning with a grid-based system — only checking collisions between fish in the same or adjacent grid cells. This brought collision checks back to constant time per fish for typical densities.

Results

  • Smooth 60fps gameplay even with 50+ active fish
  • Spatial partitioning for efficient collision detection
  • Polished arcade feel with momentum-based movement and parallax backgrounds

Interested in working together?

Let's Talk