The Pythagorean Theorem in Games

a² + b² = c²

1

The Problem: How Far Away Is It?

In games, we constantly need to know distances. Is the player close enough to pick up the item? Is the enemy in attack range? Should this sound be loud or quiet? Click anywhere to place a player, then see how we calculate the distance to the enemy.

Click anywhere to move the player (blue)

0
Horizontal (Δx)
0
Vertical (Δy)
0
Actual Distance

❌ Can't Just Add

Horizontal + Vertical doesn't give the true distance. That would be walking around a corner!

✓ Need Diagonal

The real distance is the straight line - the diagonal of the rectangle formed by Δx and Δy.

2

The Hidden Right Triangle

Every time you need a distance between two points, there's a right triangle hiding in the coordinates. The horizontal difference is one leg, the vertical difference is the other, and the distance is the hypotenuse!

a² + b² = c²
The Pythagorean Theorem - works for ANY right triangle!
14400
a² (120²)
8100
b² (90²)
150
c = √(a² + b²)
💡 Fun Fact

This formula is over 2,500 years old! Pythagoras proved it around 500 BCE, and now it runs billions of times per second in video games.

3

The Distance Formula

Click anywhere on the canvas to place two points. The distance formula finds how far apart they are using the Pythagorean theorem. This exact calculation happens constantly in every game!

Click to place points (alternating Point 1 and Point 2)

d = √((x₂-x₁)² + (y₂-y₁)²)
The Distance Formula - Pythagoras in coordinate form!

📍 Any Two Points

Works for any two points in 2D space, no matter where they are!

🎮 Used Constantly

Every frame, games calculate dozens of distances for collision, AI, and more.

4

How Games Use Distance

The distance formula is used for so many game features! Click each tab to see different examples of Pythagoras in action.

Move your mouse to see collision detection in action. Objects collide when their distance is less than the sum of their radii!
5

Test Your Understanding!

Time to put Pythagoras to work! Collect the targets (green) while avoiding the enemies (red). The game uses the distance formula to check if you've touched anything!

0
Score
30
Time

Use arrow keys or WASD to move

🎮 Behind the Scenes

Every frame, the game calculates the distance from you to every target and enemy using √((x₂-x₁)² + (y₂-y₁)²). If distance < radius sum, collision!

6

Going 3D!

In 3D games, we just add one more dimension! The formula becomes d = √(Δx² + Δy² + Δz²). Drag to rotate the view and see how 3D distance works.

4
ΔX
3
ΔY
2
ΔZ
5.39
Distance

🎮 Used In

Minecraft, Fortnite, Call of Duty, and every 3D game ever made!

🚀 Same Concept

It's still just Pythagoras - applied twice! First for XY, then add Z.

🌐 Real World Too

GPS navigation, drone flight paths, and robot movement all use this!

💡 Fun Fact

The Pythagorean theorem is used so often in game engines that it's typically optimized at the hardware level. Your graphics card has special circuits just for calculating square roots faster!

Distance Master!

You've discovered the secret formula that powers every video game! From ancient Greece to modern gaming, the Pythagorean theorem keeps measuring distances.

0
Triangles Explored
0
Game Score
0
Time Exploring

The Hidden Triangle

Any two points form a right triangle with the axes

a² + b² = c²

The 2,500-year-old formula that powers modern games

Distance Formula

d = √((x₂-x₁)² + (y₂-y₁)²) for any two points

Game Applications

Collision, AI, sound, and much more use this constantly

Ready to Create?

Put your new knowledge into practice!

Suggest a Correction