From a Prompt to a Playable Game: My Amazon Q CLI Experiment

Ruchir DixitRuchir Dixit
5 min read

While exploring the recent trend of vibe coding (a topic I’ll cover in another blog), I stumbled upon Amazon Q Developer CLI through an exciting campaign called Build Games with Amazon Q CLI That’s where my curiosity kicked in, and I decided to give it a try!

In this blog, we will understand what is Amazon Q Developer CLI, How did I setup it up locally and how I used it to build a simple 2-D game in Java in just a few mins!!

What is Amazon Q Developer CLI

Amazon Q Developer CLI is a command-line tool that helps developers write, understand, and troubleshoot code more efficiently using AI. It acts as your AI coding assistant directly in your terminal, helping you:

  • Generate code in multiple languages

  • Explain code snippets and concepts

  • Refactor or debug code

  • Create new projects, solve coding challenges, and build applications

Amazon Q CLI is designed to boost developer productivity by integrating seamlessly into your local development environment.

As part of above mentioned Amazon’s campaign, I decided to create a simple 2-D game using Java ( Why Java? Because every other tutorial was in Python! ) just by giving a prompt to Q CLI and it created a fully functional 2-D Game!

Let’s see how I created this simple game in just few mins, with the help of Amazon Q Developer CLI!

Prerequisites

Here’s what you’ll need:

  • An AWS Builder ID (sign up for free at community.aws) - You will need an AWS account

  • Ubuntu / MacOS / Any other Linux Distros / Windows

    (For Windows users : You will need Windows Subsystem for Linux (WSL) since Q CLI is not natively supported on Windows)

  • Java JDK 17 or higher installed ( Since I used Java, you can choose any programming language of your choice)

  • Amazon Q CLI installed

Since , I prefer Linux (for ease of using it), I used Ubuntu for this project.

Setting up our environment

After you have met all the prerequisites, installing the Amazon Q Developer CLI is a breeze.

To install Amazon Q for the command line, refer to the link below and find the section for your operating system:

https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html

Once you have completed your installation, verify if it is successfully installed with below command:

q

If installation is successful, you should see output as below:

Now, use below command to start building!

q chat

As part of the project I wanted to created a simple java game using java, for which I gave below prompt:

Create a simple 2D Java game using Java Swing. The game should have the following features:
- A player-controlled character (e.g., a square or image) that can move left, right, and jump.
- The player collects coins scattered on the screen.
- There are enemies that move back and forth; if the player touches an enemy, they lose a life.
- Display the player's score and lives at the top of the screen.
- When the player collects all coins or loses all lives, display a "Game Over" or "You Win" message.
- Add basic keyboard controls for movement: left arrow, right arrow, and spacebar for jumping.
- The game should run smoothly in a JFrame and update the game state using a game loop.

After this it starting Thinking… and in few seconds gave me following output which had the java code for the game using Java Swing divided in multiple files (for code readability), and also steps on how can i run and test the game!

This is the output that Q Developer gave me :

It gave me a detailed explanation of the files it created, purpose of each file and also instructions on how can I play the game!!

It all seemed a bit unrealistic to me, and I thought I would definitely encounter some issues while running the code provided by the Q CLI. So, I decided to first review and understand the code to make it easier for me to debug any errors or challenges during execution.

But to my surprise, it ran perfectly fine!

I have attached screenshot of the game it created for me just on the basis of my prompt!

Home page ( to start the game )

Amazing to start with, especially for beginners, isn’t it?

Definitely this is just a simple game, having basic UI on basis of my prompt. We can add more features to it like improving UI, adding background noise, etc by giving prompts to the Q chat.

Wrapping Up

This entire experience with Amazon Q Developer CLI has been nothing short of fascinating. The fact that I could create a fully functional Java game in just a few minutes, simply by describing what I wanted in plain English, showcases the immense potential of AI-powered developer tools like Q CLI.

While this was just a simple 2D game to begin with, the possibilities are endless. You can continue experimenting by giving more detailed prompts, adding new features, and even exploring other programming languages. This is a perfect starting point for beginners, and a powerful productivity booster for seasoned developers alike.

If you’re curious about how AI can supercharge your coding workflow, I highly encourage you to give Amazon Q CLI a try, play around with it, and see where it takes you!

GitHub Link of the project : https://github.com/RuchirDixit/Amazon_Q_CLI_Game

YouTube video link of game (running) : https://www.youtube.com/watch?v=PSugU6JjELo

References:

Amazon Q CLI Documentation

Follow me :

X (formerly twitter) : Ruchir Dixit

LinkedIn : Ruchir Dixit

0
Subscribe to my newsletter

Read articles from Ruchir Dixit directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ruchir Dixit
Ruchir Dixit

Hey 👋, Ruchir Dixit here! I am currently a Java backend developer at eQ Technologic, Pune, a product based company. I love learning new technologies and building projects while learning. About my Non tech side, I love travelling and trekking. An avid motorcycle enthusiast and Basketball sports player/fan. Lets Connect on LinkedIn, Instagram or GitHub to grow together.