DEV Community

Cover image for 🚀 How I Built “Cosmic Defenders Enhanced” Using Just Prompts with Amazon Q CLI
Gagan jha
Gagan jha

Posted on

🚀 How I Built “Cosmic Defenders Enhanced” Using Just Prompts with Amazon Q CLI

“What if you could build a complex 2D shooting game by simply talking to your command line?”

That’s the power I experienced with Amazon Q CLI—a developer-focused AI assistant that helped me build a complete space shooter, Cosmic Defenders Enhanced, with just a prompt.

🎮 Why I Chose a Space Shooter Game
I’ve always been fascinated by space-themed arcade games—fast-paced action, futuristic weapons, boss fights, and engaging power-ups. I wanted to build something that’s not only fun to play but also a testament to good software engineering and modern Python game design.

A space shooter was perfect:
✔️ Visually engaging
✔️ Technically challenging
✔️ Ideal for experimenting with AI-generated logic, physics, and UI

💡 Prompting Techniques that Worked Like Magic
Getting meaningful results from Amazon Q CLI wasn’t just about typing what I wanted—it was about speaking developer language to an AI.

🧠 Here’s what I learned:
Be specific: "Build a 2D shooting game with 3 enemy types and 4 bullet patterns."
Use verbs that express behavior: “Add a leaderboard that updates after each game.”
Think modularly: “Make a separate module for particles, audio, UI, and state management.”
Request features with constraints: “Cap bullet count to 200 for performance.”
With clear intentions and a layered approach, I could guide Q CLI through building complex systems that normally take weeks.

🧠 How AI Handled Classic Game Dev Challenges
Building any game manually involves dozens of steps—Q CLI accelerated the process dramatically. Here's how it tackled common programming challenges:

🎯 State Management
Q CLI implemented a Finite State Machine (FSM) to manage game states like splash screen, menu, gameplay, pause, and game over—with clean transitions.

🎮 Physics and Collision
Using simple prompts, I got pixel-perfect collision detection and velocity-based motion with acceleration, friction, and bounds checking.

🧠 Enemy AI
With commands like “Make enemies that follow sine wave motion” and “Add multi-phase boss logic,” Q CLI built diverse enemies from BASIC to BOSS classes with distinct patterns and adaptive behavior.

⚙️ Automation That Saved Me Hours
Amazon Q CLI automated multiple areas of development, including:
Task Time Saved
Creating base architecture (ECS, FSM) ~4 hours
Generating UI menus and settings ~2 hours
Writing boilerplate for player, enemy, bullet modules ~6 hours
Handling save/load systems (JSON, leaderboard) ~2 hours
Testing support and config files ~3 hours

Without touching boilerplate, I focused on gameplay, design, and optimization.

📌 Code Examples: Smart AI-Powered Solutions
Here are just a few standout code snippets that were generated via Q CLI:
💥 Circular Bullet Pattern
def shoot_circular(self):
for angle in range(0, 360, 15):
rad = math.radians(angle)
dx = math.cos(rad)
dy = math.sin(rad)
self.spawn_bullet(self.x, self.y, dx, dy)

👾 Enemy Behavior State Machine
class BossPhase(enum.Enum):
SPREAD = 1
CIRCLE = 2
SEEK = 3
def update_boss(self):
if self.phase == BossPhase.SPREAD:
self.shoot_spread()
elif self.phase == BossPhase.CIRCLE:
self.move_in_circle()
elif self.phase == BossPhase.SEEK:
self.seek_player()

🧠 Object Pooling for Bullets
def get_bullet(self):
for bullet in self.bullet_pool:
if not bullet.active:
return bullet
return None # Prevent spawning more than allowed
These aren’t toy examples—they’re production-quality code. All of it AI-generated with little to no tweaks.

Image description

Image description

Image description

Image description

📁 GitHub & How You Can Try It
You can explore the entire source code and run the game from the repo below:
🔗 GitHub Repository: https://github.com/jhaGagan0/cosmic-defenders-enhanced

🚀 Final Thoughts: AI + Developer = Superpowers
This project taught me that AI isn't here to replace developers—it’s here to amplify our creativity.
With Amazon Q CLI, I went from idea to professional-level game in a fraction of the time it would normally take. The code is clean, modular, extensible, and performs at 60 FPS even with 500+ particles on screen.

This game isn’t just a fun project—it’s a portfolio piece, a learning milestone, and a glimpse into the future of coding.

🙏 Special Thanks
Big thanks to the team behind Amazon Q CLI for opening up this opportunity to explore what’s possible with prompt-driven development.

👇 Let me know what you think in the comments!
Would you try building your next project using Q CLI?

AmazonQCLI #PythonGameDev #PromptEngineering #AIInCoding #OpenSource #StudentDeveloper #BCA #PortfolioProject

Top comments (0)