Explain the core mechanics of the old popular pc game, Zuma's Revenge

Thirdpen

The Mechanics of Zuma

How radial puzzle games manage path following, collision detection, and chain physics.


Path Following: Bezier Curves

At the heart of the game is the marble chain. The balls don't move randomly; they follow a strict, pre-calculated path. In game development, these paths are often defined using Splines or Bezier Curves.

A cubic Bezier curve uses four points: a Start, an End, and two Control Points that define the curvature. The game calculates the position of every ball based on a value tt (from 0 to 1) along this curve.

Path Interpolation Simulator

Drag the slider to move the "marble" along the curve. Notice how the rotation is calculated using the tangent (the direction the curve is heading at that exact point).


Chain Management: Linked Lists

Mechanically, the balls are not just physics objects bouncing around. They are organized in a Doubly Linked List. Each ball knows which ball is in front of it and which is behind it.

When you shoot a ball, the game calculates the collision point, splits the list, and inserts the new ball into the chain.

  1. Collision: Raycast from the shooter to the curve.
  2. Split: Index ii is pushed back, Index i+1i+1 stays put (or vice versa).
  3. Insertion: The new ball takes the empty slot.

Insertion Logic Demo

Click on any gap or ball to "shoot" a new ball into that position. Watch how the array shifts to accommodate the new data.


The "Magnet" Physics (Gap Closing)

The most satisfying mechanic in these games is the Reverse Attraction.

When you destroy a group of balls, a gap is created.

  1. The game checks the ball before the gap and the ball after the gap.
  2. If they are the same color, a "magnetic" force is activated.
  3. The chain furthest from the exit is pulled violently towards the chain closer to the exit, closing the gap.
  4. If they collide, a new combo check is triggered.

Magnetic Attraction Simulator

Destroy the middle balls to create a gap. If the ends match, watch the Attraction Force pull the back chain forward.


Putting it Together: The Engine

To build the full experience, the engine runs a constant loop:

  1. Advance Path: Increase the tt value for the "Lead Ball".
  2. Constraint Solving: Update every subsequent ball's position to be exactly radius * 2 distance behind the lead ball along the curve.
  3. Shooter: Calculate rotation angle relative to mouse.
  4. Projectile: On click, spawn a projectile with velocity vector (vx,vy)(v_x, v_y).
  5. Collision Check: Every frame, check distance between projectile and all chain balls.

Interactive Prototype

This is a simplified version of the engine. Aim with your mouse/touch and click to shoot.

Sign in to ask follow ups

Sign In to continue