Introduction
Recently, I participated in the Amazon Q challenge by creating a classic Asteroids game using Python and Pygame. What made this project unique was leveraging Amazon Q's AI capabilities to assist with the development process.
For the organizers and anyone who wants to play this game:
- Clone this GitHub repository for the game codebase,
- Go to folder
aws-q-game-challenge
- Run
source venv/bin/activate
in bash - Run
python asteroids.py
in bash.
In this blog post, I'll share how I set up Amazon Q
CLI, the prompts I used to create the game, and how I enhanced it with custom assets.
Setting Up Amazon Q CLI
Before diving into game development, I needed to set up Amazon Q CLI on my macOS system. Here's how I did it:
Download the AWS Q CLI (if not already installed) from this link: AWS Q CLI for MacOS
Start a chat session:
q chat
With Amazon Q CLI set up, I was ready to build my game.
The Development Process
Initial Game Creation
I started by asking Amazon Q to help me create a basic Asteroids game. My first prompt was:
"I want to create a game using pygame, named asteroid_game. Can you help me with the basic structure?"
Amazon Q provided me with a complete initial implementation that included:
• Game window setup
• Player spaceship controls
• Asteroid generation
• Collision detection
• Scoring system
• Game loop structure
The initial version used simple geometric shapes for the spaceship and asteroids, which worked well but lacked visual appeal.
Enhancing with Real Images
To make the game more visually appealing, I asked Amazon Q:
"I've created a game using pygame, named asteroid_game. I want to use real stone images and a real spaceship for shooting."
Amazon Q then:
- Created an assets directory structure
- Modified the code to load and use external images
- Added fallback mechanisms if images weren't available
- Provided guidance on where to find free game assets
Customizing the Spaceship
I wanted to make the spaceship more prominent, so I used this prompt:
"Make the spaceship a bit bigger and move it to more bottom side of the game screen."
Amazon Q adjusted the code to:
• Increase the spaceship size from 40x50 to 60x75 pixels
• Position the ship closer to the bottom of the screen
• Adjust the bullet spawn position to match the new ship size
Game Assets
For the visual elements of the game, I used the following assets:
- Spaceship: A top-down view spaceship image (spaceship.png) placed in the assets folder
- Asteroids: Three different asteroid images for different sizes: • asteroid_large.png • asteroid_medium.png • asteroid_small.png
- Sound Effects: A laser.wav file for the shooting sound
I sourced these assets from free game asset websites like:
• OpenGameArt.org
• Kenney.nl (which has excellent space game assets)
• Itch.io (free assets section)
Key Features of the Game
The final game includes several features that make it engaging:
- Progressive Difficulty: As your score increases, the game levels up, and asteroids appear more frequently
- Asteroid Splitting: When shot, larger asteroids split into smaller ones
- Lives System: Players have multiple lives before game over
- Invulnerability Period: Brief invulnerability after being hit
- Visual Effects: Stars moving in the background for a space atmosphere
- Score Tracking: Points awarded based on asteroid size
Lessons Learned
Working with Amazon Q to develop this game taught me several valuable lessons:
- AI-Assisted Development: Amazon Q can significantly speed up development by providing complete, working code examples.
- Iterative Improvement: Starting with a basic version and enhancing it step by step worked well.
- Asset Integration: Adding real images greatly improved the visual appeal with minimal code changes.
- Prompt Engineering: Being specific in my requests to Amazon Q yielded better results.
Conclusion
Creating an Asteroids game with Amazon Q was a fascinating experience that demonstrated how AI can assist in game development. A combination of Amazon Q's code generation capabilities and my creative direction resulted in a fun, playable game that I'm proud to submit for the challenge.
The most impressive aspect was how quickly I could iterate on the game design, from basic shapes to a visually appealing game with real assets, all through conversational prompts with Amazon Q.
If you're interested in game development but find coding challenging, or if you're an experienced developer looking to speed up your workflow, I highly recommend giving Amazon Q a try. It's like having a knowledgeable programming partner who's always ready to help.
This project demonstrates the potential of AI-assisted development tools like Amazon Q to democratize game creation and make coding more accessible to everyone.
Top comments (3)
this looks super fun to mess around with - been cool seeing steady progress like that, it always adds up imo. you think the spark to keep building comes more from using fresh tools or just finding ways to make things yours?
Nice work, thanks for sharing!
Love how you took it from basic shapes to a full game with real assets just by iterating prompts, that's super motivating. Have you tried doing something similar with any other AI tools?