At the beginning of June, I saw a post related to Amazon Q which was 'Build Games with Amazon Q CLI and score a T-shirt'. I always wanted to experience how Amazon Q works, so I decided to spend a weekend gaining hands-on experience by building a game. Nevertheless, as a bonus, I can win a T-shirt as well. haha 😉
Here’s what I did.
Actually, all the steps and resource links are provided in the post itself, so anyone can go through it without any hassle.
First I had to sign up to an AWS Builder ID and claim the unique community.aws username.
Then, installed the Amazon Q CLI on my Windows machine. To achieve this I had to install WSL for Windows as well. I installed PyGame the game engine. Even though the original post says we can use any game engine I went with the post-suggested game engine which was PyGame.
Unfortunately, I didn't see the installation steps for Mac OS. I think installation for Mac OS is under Linux.
Afterwards, we can open a terminal and type wsl -d ubuntu
and it will create a Ubuntu distribution on a Windows machine. Then we can log in to Q cli by q login
. It will prompt,
We can use the 'Use for Free with Builder ID' option. Once selected, it gives a URL to verify a code from the browser. You can follow the steps easily.
After clicking the URL, it opens in the browser.
Then, it asks for permission to allow access to Amazon Q.
After granting access, the terminal displays a success message.
After the device successfully authenticated, by typing q chat
it starts Amazon Q CLI.
The first prompt I typed to build the game was 'Hi, can you please help me to build a game by using a PyGame gaming engine?'
After giving updates and correct requirements finally I built not 1 game but 2 games 🤞
First, I built a game which is similar to brick braking game but instead of brick braking, I built it to just keep the ball in the screen. I always wanted to build a game which is simpler than brick gaming and allows the users to play the game for more time and waste time on the game. 😉
While giving instructions/requirements to Amazon Q CLI, I found that it responds correctly if we give the instructions simply and to the point. For example, when we want to define how many lives the user has and the ball speed, colours (background, ball, stick)...etc. While feeding the Q CLI we can tell those things to it and it will generate accordingly.
I was amazed by the output and how the Amazon Q CLI handled classic programming challenges so efficiently. Because of this, I started building another game—something similar to Pac-Man. Instead of Pac-Man, I asked Amazon Q to create a game where a police officer chases donuts 😄.
In this game, the player controls a police officer, and donuts appear along a maze-like path. The goal is to move the officer through the maze to collect (or "eat") the donuts.
In this game also Amazon Q handled all classic programming challenges and built the game according to my instructions and similar to Pacman. I didn't give much information I just replaced those characters with a policeman and donuts and Q CLI was able to give me the correct output that I expected.
Amazon Q generated python code segment
In the above code segment you can see how the Q CLI coding is done, comments and meaningful names which is next level of coding.
These are the screenshots of my 2 games I built using Amazon Q CLI.
Final output of the Ball Bounce Game
Final output of the Police Donut Chase Game
Conclusion
As a developer, I know how challenging it can be to build a game, even a simple 2D game by using PyGame engine. That’s why I found Amazon Q CLI truly impressive. It allowed me to build a game in just a few minutes. It was an awesome learning experience and a weekend well spent with Amazon Q.
Hey talented devs! Airdrop alert! We're offering free tokens to celebrate our authors' impact in Web3. Head over here (wallet connection required). – Dev.to Airdrop Desk