This content originally appeared on DEV Community and was authored by Yashvi Kothari
Building a Pac-Man Inspired Game with Amazon Q CLI
By Yashvi Kothari
Published: June 27, 2024
Introduction
amazon q
It turns out a simple, 200-line Pac-Man demo into a full-fledged, 2000+ line game using Amazon Q CLI. Along the way, I learned how AI can speed up development, sharpen prompting skills, and shape the future of coding.
Why Pac-Man?
- Complexity in layers—from basic movement to ghost AI.
- Real-time needs: 60 FPS, collision checks, responsive controls.
- Familiar rules make it easy to judge quality.
- Clear specs help shape prompts.
Core Challenges
- Rendering with HTML5 Canvas
- Collision detection (walls, ghosts, dots)
- Ghost pathfinding and behaviors
- State management (levels, lives, scores)
- Audio via Web Audio API
- Performance tuning
Mastering AI Prompting
https://youtube.com/shorts/ALgU6YR8Kkc
From Broad to Precise
Too vague:
"Create a Pac-Man game"
→ Minimal outputMore detail:
"Make an 800×440 Canvas game with:
- Grid movement
- Wall collisions
- Dot collection
- Score tracking"
→ Working prototype
- Contextual ask:
"Add four ghost AIs:
- Blinky (chases Pac-Man)
- Pinky (ambushes ahead)
- Inky (patrols)
- Clyde (random)
Ensure proper pathfinding."
→ Distinct ghost behaviors
Prompting Tips
- Iterate: Build feature by feature.
- Keep context: Refer to earlier code.
- Break problems down: Solve movement → input buffering → corner turns.
- Be specific: Provide dimensions, rates, algorithms.
Tackling Key Problems
Youtube Video | Hindi-ENglish (Hinglish)
https://www.youtube.com/watch?v=iMuAm4wQ2vE
Working as per AI but not even ready for local/test setup
- try to first verify what commands fall under root permissions
- verify port is up & running
Collision Detection
AI generated both:
function checkCollision(a, b) { … } // Circle vs. circle
function checkWallCollision(e, dir) { … } // Grid-based
Ghost AI Behaviors
State machine per personality:
switch (ghost.type) {
case 'aggressive': target = pacman.pos; break;
case 'ambush': target = ambushPos(); break;
…
}
ghost.pathfind();
Performance
- Object pooling for particles
- Dirty-rectangle rendering
- Frame-limited loop with
requestAnimationFrame
Automating Development
Tests
AI wrote unit and integration tests:
test('collect dot', () => { … });
test('ghost collision', () => { … });
Docs & Assets
Generated API docs and CSS animations:
@keyframes pacman-chomp { … }
When AI Surprises
Audio System
Full Web Audio API class without prompt:
class AudioSystem {
generateTone(freq, dur) { … }
play('dot');
}
Input Buffering
Handles rapid inputs and old entries:
inputBuffer.push({dir, time});
processBuffer();
Testing & Bug Fixes
- Manual: Unit → integration → UX tests.
- Automated: AI-generated test suites.
-
Bug fixes:
- Hidden loading screen
- Pause button state issues
Final Product
- Code: 2000+ lines, 15+ files
- Features: Ghost AI, particle effects, achievements, mobile support
- Performance: Steady 60 FPS on major browsers
- Deployment: Live on GitHub Pages
Live URLs (After Deployment):**
• Main Game: https://yashvikothari.github.io/pacman
• Original Version: https://yashvikothari.github.io/pacman/versions/v0.1/
• Working Version: https://yashvikothari.github.io/pacman/versions/v2.0.1-working/
• Flexible Version: https://yashvikothari.github.io/pacman/versions/v2.0.1-flexible/
Audio & other version is not deployed here !
Lessons Learned
- AI multiplies, not replaces, your skills.
- Prompting is an art—detail and context matter.
- AI handles boilerplate, tests, docs well.
- Human oversight is key for architecture, UX, and performance.
What I’d Do Differently next time
- Better upfront architecture planning
- Test-driven prompts
- Smaller, frequent commits with feature branches
- Living documentation alongside code
- integrate with git first
Recommendation
Yes, for prototyping, learning, and solo projects—if you:
- Practice prompting
- Understand generated code
- Review performance
- Pair AI with your own creativity
Conclusion
This Pac-Man project shows how AI can help you go from a rough demo to a polished game in hours. Treat AI as a coding partner, iterate often, and combine your creativity with AI efficiency to build amazing things faster than ever.
This content originally appeared on DEV Community and was authored by Yashvi Kothari

Yashvi Kothari | Sciencx (2025-06-27T18:19:02+00:00) Amazon Q in Action ! Pacman Inspired game deployed. Retrieved from https://www.scien.cx/2025/06/27/amazon-q-in-action-pacman-inspired-game-deployed/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.