| 1 | /** Linger time before the first bug crawls out on the landing page. */ |
| 2 | export const BUG_DELAY_MS = |
| 3 | |
| 4 | /** One more bug joins every interval while the visitor stays. */ |
| 5 | export const BUG_SPAWN_INTERVAL_MS = |
| 6 | |
| 7 | /** The invasion stops here, so the page stays usable. */ |
| 8 | export const MAX_BUGS = |
| 9 | |
| 10 | export interface LandingBug |
| 11 | id: number; |
| 12 | /** Viewport percentages, so a resize never strands a bug off-screen. */ |
| 13 | x: number; |
| 14 | y: number; |
| 15 | /** Tilt in degrees. */ |
| 16 | angle: number; |
| 17 | } |
| 18 | |
| 19 | /** A bug at a random spot and tilt, kept away from the far edges. */ |
| 20 | export function createBug( |
| 21 | id: number, |
| 22 | random: () |
| 23 | ): LandingBug { |
| 24 | return { |
| 25 | id, |
| 26 | x: random() * |
| 27 | y: random() * |
| 28 | angle: Math.floor |
| 29 | }; |
| 30 | } |