quest

Sign in to start training

quest keeps your progress, streaks, and scores tied to your account — so you can pick up on any device.

Synced everywhere. Progress follows you across laptop and phone.
Streaks & stats. See your daily run and every score over time.
Your profile. A name and avatar for the work you do here.

We only use Google to sign you in and sync progress. No posting, no contacts — ever.

Game Dev Advanced

22  Collision

Axis-aligned boxes are the workhorse of game collision. Detect when two overlap, then keep a point inside an arena with clamp.

Step 1 / 2

Implement overlaps: true when the two boxes intersect. Touching edges don't count.

Hints
  • Two boxes overlap when they overlap on BOTH axes.
  • Per axis: a.x < b.x + b.w && b.x < a.x + a.w -- strict < makes a touching edge 'no overlap'.
22_collision.rs
Reset to starterCompiled in a sandbox; hidden checks must pass.
Reveal solution
#[derive(Clone, Copy)]
struct Aabb { x: f32, y: f32, w: f32, h: f32 }

fn overlaps(a: Aabb, b: Aabb) -> bool {
    a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h
}