AWS Logo
Menu
How I created a 2048 game with Amazon Q CLI

How I created a 2048 game with Amazon Q CLI

A sliding title puzzle game for kids

Published Jun 9, 2025

Overview

In this blog, I showcased a simple 2048 game which a single-player sliding tile game for kids aged 7 -13. The game is available on GitHub along with all necessary dependencies, making it easy to run in GitHub Codespaces and deploy on cloud platforms like Vercel or Streamlit.

Environment Setup

Windows setup

This was an easy part. I had to use WSL 2 for Windows. The distro I used is Ubuntu 24.04 LTS. I followed guidelines provided in this link. This is an amazing blog by Ricardo Sueiras with video tutorials for installing Amazon Q Developer CLI on Windows.
Just to ensure everything is set, I ran the following command:
Screenshot of running q doctor
Run 'q doctor' in the Ubuntu terminal

Game Engine

For the sake of creating this game, I used pygame which is an open source cross platform library for the development of multimedia applications like video games using Python. To install, I ran the following command,
To start the interactive chat with Amazon Q CLI, I ran the following command:
interactive chat with Amazon Q
Run 'q chat' in the terminal

Prompts Used

I created a detailed prompt which is fine-tuned by an LLM as follows:
"Create a fun and engaging 2048 game using Pygame, designed specifically for kids aged 7–13. The interface should feature bright, colorful graphics, large buttons, child-friendly fonts, and an option to switch to a dark theme (toggleable via a settings menu).
Include an interactive tutorial popup with 3–5 slides that automatically appears when the game is launched for the first time. The slides should include:
  1. Game objective (create 2048 tile)
  2. How to move tiles using arrow keys
  3. Merging rule (e.g., 2 + 2 = 4)
  4. What causes the game to end
  5. Optional: Tips and tricks or reset instructions
Additional features to include:
  • Smooth animations for tile movements and merges
  • Sound effects when tiles merge
  • Score tracking and a simple restart button
  • A toggle switch for light/dark theme in settings
Prepare a GitHub repository with:
  • A detailed README (setup instructions, gameplay explanation, screenshots, how to contribute)
  • A MIT license
  • A standard SECURITY.md following GitHub’s basic template
  • A requirements.txt file listing all dependencies (or a pyproject.toml if preferred)
  • A .devcontainer folder with configuration files to support running the game in GitHub Codespaces
Python Version: Python 3.11+ (or your latest compatible)
Pygame Version: Latest stable version (specify in requirements)
Game Description:
What is 2048?
2048 is a single-player sliding tile puzzle game created by Gabriele Cirulli in 2014. The goal is to combine numbered tiles on a 4×4 grid to create a tile with the number 2048.
How it works:
  • Use arrow keys to slide all tiles.
  • When two tiles with the same number touch, they merge.
  • A new tile (2 or 4) appears after every move.
  • The game ends when no moves are possible.
  • The player wins when a tile with 2048 appears."
I needed to improve the UI and added the following prompt:
Add spacing between the "Score" display and the game tiles to enhance visual clarity. Replace the textual settings label with a settings icon (e.g., a gear icon) to make the interface cleaner and more intuitive for kids.
For further improvements, I added the following prompt:
Please address the following UI improvements: The "Restart Game" button currently overlaps with the game tiles. Adjust its position or layout to ensure it remains visually separated and does not obstruct gameplay. Implement scroll bars or responsive scaling so that when the window size is reduced, all UI elements (including tiles and buttons) remain accessible without overlapping or cutting off content.

Generated Output

Screenshot of Kids 2048 in Light Theme
Kids 2048 game in Light Theme
Screenshot of Kids 2048 in Dark Theme
Kids 2048 game in Dark Theme

Lessons Learned

Some of the key learnings I received through this game are as follows:
  1. AI coding assistants can dramatically accelerate the development phase without the need for starting from scratch. This helped me to focus more on the UX of the game through iterative improvement.
  2. Pygame: This open source library is a starter for young game developers rather than inventing a wheel which is already built.
  3. Prompt Engineering: Providing Amazon Q with specific and detailed prompt helps to create an Minimum V

Future Enhancements

There are lot of improvements which could be done. Here are a few:
  1. Kid friendly UI improvements
  2. Sound generation when a point is earned

Conclusion

The Amazon Q CLI is an excellent starter for new developers. It helped to create a kid friendly game with iterative prompts which helped me refine the UI and UX of the game. It bridged the gap between generative AI and human interaction. It helped me focus more on the broader aspect of the game and on the other hand it took care of the boilerplate code generation.

Reference

The cover image is generated with Ideogram.ai. Reference is in this link.

Comments