DEV Community

Cover image for Amazon Q in Action ! Pacman Inspired game deployed

Amazon Q in Action ! Pacman Inspired game deployed

Building a Pac-Man Inspired Game with Amazon Q CLI

By Yashvi Kothari

Published: June 27, 2024


Introduction

amazon q

Image description

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.

Image description

Why Pac-Man?

Inspiration: https://community.aws/content/2y6egGcPAGQs8EwtQUM9KAONojz/build-games-challenge-build-classics-with-amazon-q-developer-cli?trk=b3ed9c83-eb20-4f68-b5b4-ffdc878e85c6&sc_channel=em&bb=237784

https://community.aws/content/2vlITBGRfv8slpeU1UlTrpT4bBI/vibe-coding-in-practice-building-a-super-mario-game-with-amazon-q-developer-cli

  1. Complexity in layers—from basic movement to ghost AI.
  2. Real-time needs: 60 FPS, collision checks, responsive controls.
  3. Familiar rules make it easy to judge quality.
  4. Clear specs help shape prompts.

Image description

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

Image description


Mastering AI Prompting

https://youtube.com/shorts/ALgU6YR8Kkc

From Broad to Precise

  1. Too vague:

    "Create a Pac-Man game"

    → Minimal output

  2. More detail:

   "Make an 800×440 Canvas game with:
   - Grid movement
   - Wall collisions
   - Dot collection
   - Score tracking"
Enter fullscreen mode Exit fullscreen mode

→ Working prototype

  1. Contextual ask:
   "Add four ghost AIs:
   - Blinky (chases Pac-Man)
   - Pinky (ambushes ahead)
   - Inky (patrols)
   - Clyde (random)
   Ensure proper pathfinding."
Enter fullscreen mode Exit fullscreen mode

→ 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

Image description

Collision Detection

AI generated both:

function checkCollision(a, b) {  }    // Circle vs. circle
function checkWallCollision(e, dir) {  }  // Grid-based
Enter fullscreen mode Exit fullscreen mode

Ghost AI Behaviors

State machine per personality:

switch (ghost.type) {
  case 'aggressive': target = pacman.pos; break;
  case 'ambush':    target = ambushPos(); break;
  
}
ghost.pathfind();
Enter fullscreen mode Exit fullscreen mode

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', () => {  });
Enter fullscreen mode Exit fullscreen mode

Docs & Assets

Generated API docs and CSS animations:

@keyframes pacman-chomp {  }
Enter fullscreen mode Exit fullscreen mode

When AI Surprises

Audio System

Full Web Audio API class without prompt:

class AudioSystem {
  generateTone(freq, dur) {  }
  play('dot');
}
Enter fullscreen mode Exit fullscreen mode

Input Buffering

Handles rapid inputs and old entries:

inputBuffer.push({dir, time});
processBuffer();
Enter fullscreen mode Exit fullscreen mode

Testing & Bug Fixes

  1. Manual: Unit → integration → UX tests.
  2. Automated: AI-generated test suites.
  3. Bug fixes:
    • Hidden loading screen
    • Pause button state issues

Image description


Final Product

Image description

  • 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

  1. AI multiplies, not replaces, your skills.
  2. Prompting is an art—detail and context matter.
  3. AI handles boilerplate, tests, docs well.
  4. 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

Image description

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.

Top comments (0)