This is a self-contained HTML document that creates a bouncing ball inside a spinning hexagon, with realistic gravity, friction, and wall collisions. It includes Pause/Resume and Reset buttons plus keyboard shortcuts for quick control.
```html
Bouncing Ball in a Spinning Hexagon
Space = Pause / Resume · R = Reset
```
### Simulation Mechanics & Controls
This little physics sandbox gives you a ball, a rotating hexagon, and a few buttons to play with. Here's what's happening under the hood.
- **Real-time physics**: The ball responds to gravity, air drag, and friction. Each collision with a wall uses the wall's rotational velocity, so bounces feel natural even as the hexagon spins.
- **Fixed-timestep loop**: The simulation runs in small, fixed steps (1/300 s) to keep collisions stable, no matter your frame rate.
- **Controls**: Use the **Pause/Resume** button to freeze motion and **Reset** to send the ball back to the top with a random horizontal nudge. You can also press **Space** to toggle pause and **R** to reset.
- **Visual feedback**: A subtle motion trail follows the ball, and the hexagon glows with a soft neon edge.
---
**Optimization Tip:** You can adjust the simulation feel by changing the physics constants near the top of the script — try lowering `GRAVITY` for a floatier ball or increasing `RESTITUTION` for bouncier collisions. The ball's radius is also set there.