A small browser game where you watch bugs swarm a light
Translated by AIView original
What problem is this?
You want to know why bugs gather under the porch light on summer nights, but most of the material is long papers. The research summaries say LED lights attract far fewer insects than incandescent bulbs or small fluorescent tubes. Still, it's rare to actually see how much difference a switch makes. A small tool where you pick a light type and see the result right away, with no setup or hardware to buy, would be nice.
How about building it this way
Make a small screen that opens in the browser. Put a street lamp in the middle and have dozens of bug dots fly toward the light. Add buttons to pick the light type, like incandescent, fluorescent with UV, cool white LED, and warm white LED. Have the bugs follow a rule where they turn toward the light based on UV as a cue. When you switch lights, show the number of bugs gathered on screen as a count. One screen is enough for a first version. After that you could add options to change the time of night or the light height. Once it's done, it's also handy to show your family when you're picking a balcony light.
Difficulty and tools
- Difficulty: weekend project
- Suggested tools: HTML Canvas, p5.js, vanilla JavaScript
Starting prompt for vibe coding
브라우저에서 바로 여는 단일 HTML 파일 하나로 만들어 주세요.
만들 것은 조명 종류에 따라 벌레가 얼마나 모이는지 보여 주는 작은 시뮬레이션입니다.
핵심 기능은 다음과 같습니다.
1. 화면 가운데에 가로등 하나를 그리고, 벌레 점 40개를 무작위 위치에 흩어 놓습니다.
2. 조명 종류 버튼 4개를 둡니다. 백열등, 자외선 섞인 형광등, 차가운 백색 LED, 따뜻한 백색 LED입니다.
3. 벌레는 빛 방향으로 천천히 이동하되, 조명 종류에 따라 끌림 강도를 다르게 설정합니다. LED는 끌림을 가장 약하게 둡니다.
4. 화면 한쪽에 빛 근처에 모인 벌레 수를 실시간 숫자로 표시합니다.
첫 단계는 캔버스 하나와 벌레 점 이동 루프만 만드는 것입니다. 끌림 값은 나중에 상수로 빼 두어 쉽게 고칠 수 있게 해 주세요.
What inspired it
- Bugs don't crowd around LED lights (GeekNews)
If you make one, put a link to this post in your Showcase post and show it off.
Comments 0
No comments yet
Be the first to comment.