Interactive basketball court built with Next.js, React, Framer Motion, and Tailwind CSS.
It allows coaches or players to draw plays, simulate passes, move players with trails, and add screens (โblocksโ).
- Passing: click ball โ click player โ ball animates to target with spin & bounce.
- Ball possession: when a player has the ball, dragging them moves the ball too.
- Player movement: drag players around; dashed trails fade out behind them.
- Blocks (screens):
- Double-click a player โ show soft red wall (aim, rotates with mouse).
- Click empty court โ lock as dark red wall (lasts a few seconds).
- Click same player again while aiming โ cancel block (no lock).
- Click the ball โ it highlights (armed for pass).
- Click a player โ ball passes to them along a curve.
- When pass finishes, the ball sticks to the player.
- Click empty court โ cancels armed pass.
- Drag any player circle to move them.
- A dashed trail follows their movement and fades out.
- If the player has the ball, the ball follows during drag.
- Double-click a player (within ~600 ms) โ soft red wall (aim).
- Wall rotates toward your mouse direction.
- Click empty court โ lock the wall (dark red), stays ~2.5s.
- Click same player again while aiming โ cancel aim (no lock).
app/
layout.tsx # Root layout with fonts and globals
globals.css # Tailwind + theme variables
page.tsx # Entry point rendering <Court />
components/
Court.tsx # Core logic: passes, blocks, trails, ball handling
Player.tsx # Draggable player circle (Framer Motion)
Ball.tsx # Ball element with spin, highlight, and draggable supportNext.js (App Router)
React
Framer Motion (drag, animation)
Tailwind CSS
TypeScript
๐ Getting Started
# install deps
npm install # or: pnpm install / yarn install
# run dev
npm run dev # or: pnpm dev / yarn dev
# open in browser
http://localhost:3000
Requires images in /public/img/court.png and /public/img/basketball.png.๐ Notes Clicking empty court always cancels a pass and locks/cancels aim if active.
During pass animation, if the target player moves, ball snaps to their new position.
Trails are visual only; they donโt block or affect physics.