Creating a Space Invaders Game with Amazon Q CLI
If you think Amazon Q is cool, make a game with it on the CLI and experience the AWSomeness! That's exactly what I did and I marvelled at how easy it is.
Amazon Q as a generative AI for developers. On the CLI, it doesn't have native support for Windows. I hadd a little trouble with that but I found out that I can install it using WSL. After that, just type 'q' and voila, you're in!😎
I wanted to create the retro game called "Space Invaders" where a space ship shoots down alien invaders. All I needed to do was give Amazon Q this detailed prompt:
Create a complete "Space Invaders"-style game using vanilla HTML, CSS, and JavaScript. The game should have a player ship at the bottom that moves left and right with arrow keys and shoots bullets upward with spacebar. Rows of aliens move side to side at the top and shoot bullets downward toward the player. Players score points by destroying aliens, the score should be displayed and updated in real time, and the game should show "GAME OVER" if an alien bullet hits the ship. Provide a directory structure with index.html, style.css, and script.js files, well-commented and functional by opening index.html in a modern browser.
It requested for permission to run a shell command and I did so by typing 't'(always allow such actions for this session).
Amazon Q's Response
Amazon Q created a folder with the following files:
space-invaders/
├── index.html # Main HTML structure
├── style.css # Game styling
└── script.js # Game logic and functionality
The response included instructions on how to run the game.
Playing the game
I navigated to the folder containing the game files and ran the index.html on my browser
As requested in the prompt, the game includes:
- Player ship that moves left and right with arrow keys
- Shooting functionality with the spacebar
- Rows of aliens that move side to side and gradually descend
- Aliens that randomly shoot bullets downward
- Score tracking that updates in real-time
- "GAME OVER" display when hit by an alien bullet
- Different coloured aliens worth different point values
Well, I haven't won a game yet(the aliens keep getting me). I enjoyed how easy it is to create the Space Invaders game using Amazon Q CLI in a single prompt-response interaction. It shows just one of the many capabilities of Amazon Q on the CLI.
I hope y'all create cool games and join the challenge which ends on June 30th 2025.
Top comments (0)