1. Introduction
With the advancement of GenAI in recent years, developing a game application is no longer too time-consuming. This week, I tried using the Amazon Q Developer CLI to help me build an english learning game quickly with Python. Honestly, I had no prior experience in game development, but with the power of the Amazon Q Developer CLI, it only took me 5 minutes to complete a game that is both creative and educational. And I have to say, it’s Magic!. Therefore, I really want to share a bit of my experience to spread this magic to everyone.
2. Prerequisite
To start, you need to install Amazon Q for CLI.
· If you are using a macOS computer, refer to the Amazon Q CLI installation guide for macOS
· If you are using Linux, follow the Amazon Q CLI installation guide for Linux.
· If you are using Windows, follow this link. Note: While there is no native Windows installation yet, you can install and run Amazon Q Developer CLI on your Windows machines using the Windows Subsystem for Linux, or WSL for short. You might already have wsl installed on your machine, in which case you can skip this step. If you do not, then Microsoft have put together a blog post that walks you through this process.
In addtion, you should install PyGame or some other gaming library.
3. Here's how the game built
After successfully installing the Amazon Q CLI, let's start building our English learning game by following these steps:
Register for a Builder ID if you don't already have one.
Logging into Amazon Q Developer using a Builder ID.
You will see two login method options, which you can navigate using the up and down arrow keys. Choose the first option, "Use for Free with Builder ID."
After selecting it, you’ll be prompted to open a URL in a web browser. Copy the URL and paste it into your browser. You’ll then need to either create a new Builder ID or log in with an existing one if you already have it.
? Select login method ›
❯ Use for Free with Builder ID
Use with Pro license
Confirm the following code in the browser
Code: PNDN-IKJH
Open this URL: https://view.awsapps.com/start/#/device?user_code=PNDN-IKJH
▰▰▱▱▱▱▱ Logging in...
Congratulations, you are now ready to go ahead!
Let's start building our game with Amazon Q CLI
After completing the process, you’ll be logged into Amazon Q Developer and can access it from WSL by running the command:
q chat
Refer to the following prompt to request Amazon Q CLI to build an English learning game:
Create a Python game using Pygame that is creative, educational, and focused on learning English. The game should not use audio, have simple gameplay rules, and be suitable for beginners. The game must run in a browser using Pyodide, so ensure compatibility by avoiding local file I/O and network calls. Structure the code with an asyncio main loop, checking for platform.system() == "Emscripten" as per Pyodide requirements.
Game Requirements:
• Objective: Players learn English vocabulary or grammar through interactive gameplay.
• Gameplay: Design a visually engaging game (e.g., a word-matching puzzle, spelling challenge, or sentence-building game) where players interact using mouse or keyboard inputs.
• Educational Aspect: Include a small set of English words (e.g., 10-20 common words) or simple grammar rules (e.g., verb conjugation or sentence structure). Provide feedback on correct/incorrect answers to help players learn.
• Rules: The game should have clear, simple rules (e.g., "Match the English word to its meaning in 60 seconds" or "Type the correct word to complete the sentence"). Display the rules on the screen at the start of the game.
• Visuals: Use basic Pygame shapes or text for visuals (e.g., rectangles, circles, or text-based prompts). Keep the design simple but colorful and appealing.
• Scoring: Track the player's score (e.g., +10 points for correct answers, -5 for incorrect ones) and display it on the screen.
• Game Loop: The game should have a start screen with rules, a main gameplay loop, and an end screen showing the final score and an option to restart.
• Code Structure: Include comments explaining the code. Use a single Python file with a clear setup() function for initialization and an update_loop() function for game updates, running at 60 FPS.
Output Format:
• Provide the complete Python code for the game.
• Include a section explaining the gameplay rules clearly.
• Ensure the code is fully functional and ready to run in a Pyodide environment.
Next, you will see Amazon Q start reasoning and writing code for the game.
After about 3 minutes, Amazon Q finished building the code for the English learning game as requested. I have uploaded this code file to a GitHub repository for you all to reference.
Let's play the game
Start the game by typing the command python3
followed by the name of the built Python file.
The game interface has appeared, so let’s start playing and learning
Select your favorite topic
Upgrade the game
Enhance our game further by adding more themes for greater variety using a prompt like this:
Please add about 50 more topics to make the game more diverse.
After Amazon Q has finished building, try restarting the game and experience it.
4. Conclusion
As you can see, building a game is no longer as difficult or time-consuming as before if we know how to leverage the magic of GenAI, specifically the Amazon Q Developer CLI. Now, give it a try and share with me and everyone the game you’ve built using Amazon Q Developer CLI.
Top comments (0)