File tree Expand file tree Collapse file tree 3 files changed +164
-166
lines changed
Expand file tree Collapse file tree 3 files changed +164
-166
lines changed Original file line number Diff line number Diff line change 1- # Server Configuration
21PORT = 3000
3-
4- # Admin password for display/control page
5- ADMIN_PASSWORD = admin123
2+ ADMIN_PASSWORD = change_me_before_deploy
3+ ALLOWED_ORIGIN = *
Original file line number Diff line number Diff line change 204204 } ;
205205
206206 const calculateBallParams = ( ) => {
207- const totalBalls = Math . floor ( ( window . innerWidth * window . innerHeight ) / ballSize / ballSize ) ;
208- return { radius : ballSize , count : totalBalls } ;
207+ // Hexagonal packing efficiency ~0.9065, use 0.85 for comfort margin
208+ const r = ballSize ;
209+ const maxBalls = Math . floor ( ( ( window . innerWidth * window . innerHeight ) / ( Math . PI * r * r ) ) * 0.85 ) ;
210+ return { radius : r , count : maxBalls } ;
209211 } ;
210212
211213 // Socket events
214216 } ) ;
215217
216218 socket . on ( "ball:add" , data => {
219+ // Enforce ball cap — ignore if screen is full
220+ const { count : maxBalls } = calculateBallParams ( ) ;
221+ if ( balls . length >= maxBalls ) return ;
222+
217223 const x = Math . random ( ) * ( window . innerWidth - 200 ) + 100 ;
218224 const y = - 50 ;
219225 const radius = ballSize ;
You can’t perform that action at this time.
0 commit comments