{"slug": "how-i-fixed-the-click-bug-that-no-ai-noticed", "title": "🎯 How I Fixed the Click Bug That No AI Noticed", "summary": "A developer spent months building the Limn Engine, a game engine that runs at 60 FPS on low-end hardware, but discovered a subtle bug where click events failed when the camera moved. The bug was caused by a mismatch between screen space and world space coordinates, and it went unnoticed by five major AI models—DeepSeek, ChatGPT, Claude, Gemini, and Grok—which had all reviewed the code. The developer fixed the bug manually, highlighting a limitation in current AI code review capabilities.", "body_md": "**The story of a subtle camera bug that hid in plain sight — and how I caught it.**\n\nEvery game engine has bugs. Some are obvious — objects don't render, physics breaks, sounds don't play. Others are subtle — they only appear under specific conditions, and they're easy to miss.\n\nThis is the story of one of those subtle bugs.\n\nI spent months building Limn Engine. I tested it on a Chromebook, a Toshiba laptop with 4GB of RAM, an HP laptop (behind my sister's back), and a Tecno Pop 4 with 1GB of RAM. The engine worked beautifully — 60 FPS on low-end hardware, smooth movement, responsive controls.\n\nBut there was a problem.\n\n**Click events didn't work when the camera moved.**\n\nI noticed it while testing a game with a scrolling map. Clicking on objects worked fine when the camera was at (0,0). But as soon as the camera followed the player, clicks stopped working. Objects that were clearly on screen weren't registering clicks.\n\nI had already run the entire Limn Engine codebase through **five major AI models** — **DeepSeek, ChatGPT, Claude, Gemini, and Grok** — for evaluation and analysis. They all reviewed the code, provided feedback, and helped me optimize the engine.\n\n**None of them noticed the click bug.**\n\nThey all looked at the `clicked()`\n\nmethod and said it looked correct. They didn't consider that the mouse position was in **screen space** while the component positions were in **world space**.\n\nSo I fixed it myself.\n\nBefore I found the bug, I had already submitted Limn Engine for evaluation to the five major AI models:\n\n| AI Model | What They Evaluated | What They Missed |\n|---|---|---|\nDeepSeek |\nFull codebase, API design, performance | The camera offset in click events |\nChatGPT |\nArchitecture, features, documentation | Screen space vs. world space mismatch |\nClaude |\nCode quality, optimization suggestions | The missing `+ camera.x` in event listeners |\nGemini |\nOverall engine rating, strengths/weaknesses | Click detection with camera movement |\nGrok |\nPerformance analysis, edge cases | The space mismatch in `clicked()`\n|\n\nAll five models gave Limn Engine ratings between 88/100 and 94/100. They praised the dual-renderer system, the intuitive API, the comprehensive documentation, and the delta time fix.\n\n**But none of them caught the click bug.**\n\n| Space | What It Means | Example |\n|---|---|---|\nScreen Space |\nPosition relative to the visible screen | (100, 100) = 100 pixels from the top-left of the screen |\nWorld Space |\nPosition relative to the entire game world | (100, 100) = 100 pixels from the top-left of the world |\n\nWhen the camera is at (0,0), screen space and world space are the same. But when the camera moves — say, to (100, 100) — the relationship changes.\n\n``` js\nwindow.addEventListener('mousedown', (e) => {\n    this.x = e.pageX;   // ← Screen space\n    this.y = e.pageY;   // ← Screen space\n});\n\n// In clicked():\nclicked() {\n    const centerX = this.x + this.width / 2;\n    const centerY = this.y + this.height / 2;\n    // Uses display.x and display.y — both in screen space\n    const rotatedX = (display.x - centerX) * Math.cos(-this.angle) - (display.y - centerY) * Math.sin(-this.angle) + centerX;\n    // ...\n}\n```\n\nThe mouse position (`display.x`\n\nand `display.y`\n\n) was in **screen space**, but the component's position (`this.x`\n\nand `this.y`\n\n) was in **world space**. When the camera moved, these two spaces drifted apart, and clicks stopped working.\n\nI asked five AI models to evaluate the code. Here's what they all missed:\n\n| AI Model | What They Said | What They Missed |\n|---|---|---|\nDeepSeek |\n\"The click detection looks correct.\" | The camera offset |\nChatGPT |\n\"The rotation math is good.\" | The space mismatch |\nClaude |\n\"The `clicked()` method handles rotation well.\" |\nScreen vs. world |\nGemini |\n\"The component collision system is solid.\" | The missing `+ camera.x`\n|\nGrok |\n\"The event handling is clean.\" | The offset in mouse events |\n\nNone of them asked: *\"Wait, is display.x in screen space or world space?\"*\n\nThey assumed the code was correct because it looked like standard click detection. But standard click detection in most engines handles this automatically. In Limn Engine, it didn't.\n\nThe fix was simple once I understood the problem.\n\n``` js\nwindow.addEventListener('mousedown', (e) => {\n    this.x = e.pageX + this.camera.x;   // ← World space\n    this.y = e.pageY + this.camera.y;   // ← World space\n});\n\nwindow.addEventListener('touchstart', (e) => {\n    this.x = e.touches[0].pageX + this.camera.x;   // ← World space\n    this.y = e.touches[0].pageY + this.camera.y;   // ← World space\n});\n```\n\n**Two lines of code. That's all it took.**\n\nBy adding the camera offset (`+ this.camera.x`\n\nand `+ this.camera.y`\n\n), I converted the mouse position from **screen space** to **world space** right at the event listener level. Now `display.x`\n\nand `display.y`\n\nare always in world space, and `clicked()`\n\nworks correctly no matter where the camera is.\n\n| Scenario | Before Fix | After Fix |\n|---|---|---|\n| Camera at (0,0) | Click works ✅ | Click works ✅ |\n| Camera at (100, 100) | Click fails ❌ | Click works ✅ |\n| Camera at (500, 300) | Click fails ❌ | Click works ✅ |\n| Camera following player | Click fails ❌ | Click works ✅ |\n\n**AI is not infallible.** Five major AI models missed this bug because they don't \"think\" about context — they just analyze code.\n\n**Testing beats theory.** AI can analyze code structure, but only you can test the actual behavior.\n\n**Context matters.** The same code can be correct in one context and wrong in another. Understanding the difference between screen space and world space is essential for game development.\n\n**Test with camera movement.** Many bugs only appear when the camera moves. Always test your games with scrolling and camera following.\n\n**The simplest fix is often the best.** Two lines of code fixed a bug that confused five AI models.\n\n**Trust yourself.** I noticed the bug because I tested my game thoroughly. Don't rely on AI to catch everything — test your code.\n\nThe fixed code is live in the Limn Engine repository:\n\n**👉 Limn Engine Source Code (epic.js)**\n\nIf you encounter any issues with Limn Engine, please report them on GitHub:\n\n👉 [https://github.com/terracodes004/limn-engine-doc/issues](https://github.com/terracodes004/limn-engine-doc/issues)\n\n| Concept | Why It Matters |\n|---|---|\nScreen Space vs. World Space |\nMouse events are in screen space; game objects are in world space |\nCamera Offset |\nAdd `camera.x` and `camera.y` to convert mouse position to world space |\nAI Limitations |\nEven five AI models can miss bugs that require contextual understanding |\nTest with Camera Movement |\nBugs often appear only when the camera moves |\nTrust Your Testing |\nIf something feels wrong, it probably is — test thoroughly |\n\nNow that you understand screen space vs. world space, you can apply this knowledge to other areas of game development:\n\n\"I fixed a click bug by adding the camera offset to mouse events — two lines of code that five AI models (DeepSeek, ChatGPT, Claude, Gemini, and Grok) all missed.\"🎮🚀\n\n*Draw your game into existence — one frame at a time.* 🎮🚀", "url": "https://wpnews.pro/news/how-i-fixed-the-click-bug-that-no-ai-noticed", "canonical_source": "https://dev.to/kehinde_owolabi_e2e54567a/how-i-fixed-the-click-bug-that-no-ai-noticed-1p8o", "published_at": "2026-08-26 15:02:27+00:00", "updated_at": "2026-08-26 15:44:57.739960+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["Limn Engine", "DeepSeek", "ChatGPT", "Claude", "Gemini", "Grok"], "alternates": {"html": "https://wpnews.pro/news/how-i-fixed-the-click-bug-that-no-ai-noticed", "markdown": "https://wpnews.pro/news/how-i-fixed-the-click-bug-that-no-ai-noticed.md", "text": "https://wpnews.pro/news/how-i-fixed-the-click-bug-that-no-ai-noticed.txt", "jsonld": "https://wpnews.pro/news/how-i-fixed-the-click-bug-that-no-ai-noticed.jsonld"}}