DEV Community

SARTHAK RANA
SARTHAK RANA

Posted on

2

🕹️How I Built a 2D Endless Runner Game with Amazon Q CLI & PyGame

🎮 Introduction

As part of "Build Games with Amazon Q CLI," I decided to combine my creativity and coding skills to create a fun 2D Endless Runner Game using PyGame and Amazon Q CLI.
The result was so surprising A simple game that test our reflexes, With a player who run endlessly jumping over objects and score increasing!!
And the best part was? I built it just by chatting with Amazon Q CLI — an AI coding assistant that helps us create working code from natural language prompts. No chaos in setting up files and all.
Amazon Q CLI does everything for us!!


💡 Idea Behind the Game

I was always fascinated by the Chrome Dino Game and how it actually works so I decided to build a game something just like it.
I added mechanics like jumping to avoid obstacles, increasing the speed of the character after specific to increase the difficulty and make the game more surviving and adventurous.


🛠️ Tools & Tech & how I built it.

  • Amazon Q CLI – AI-powered coding assistant
  • Python – Programming language
  • PyGame – Library to handle graphics, events, and collisions
  • VS Code – Editor
  • GitHub – To host the code
  • Pixabay/Freesound – For free sound effects and background music

Here’s a breakdown of how I used it to build my 2D endless runner game:

Step 1: Setting Up the Environment:

To build my game, I used WSL (Windows Subsystem for Linux).
To Install WSL as Ubuntu open Powershell as Administrator and run:

 wsl --install -d Ubuntu
Enter fullscreen mode Exit fullscreen mode

Step 2:🤖 Installing Amazon Q CLI

Next I installed Amazon Q CLI I did this by following the guide

📄 Installing Amazon Q for command line

Step 3:🚀 Starting Q Chat

Once Installed start the session by simply running

q chat
Enter fullscreen mode Exit fullscreen mode

That's It! Now just give prompt to Amazon Q and our game is ready!!

My prompt was

"Help me create a simple 2D endless runner game using PyGame. I want a player character that can jump to avoid obstacles, a scrolling background or moving ground, and random obstacles appearing over time. When the player hits an obstacle, the game should end and display the final score. Also include basic scoring logic and key comments in the code."

Within minutes, Q generated a full Python script with:

  • Player and obstacle classes
  • Jump mechanics
  • Game loop with score tracking
  • Collision logic
  • Game over condition

The game generated by Amazon Q CLI used colored rectangles initially as placeholders for the player and obstacles.
This looked so boring,so I decided to add cool asset in game to make it visually appealing and engaging along with cool sound affects.
The sound effects which I added were

  • Jump sound
  • Crash sound
  • Background music

I took assests and sound from website like


Here's some snapshot and gameplay of my game

Welcome Screen
Welcome Screen

Player jumping to avoid an obstacle

Player jumping to avoid an obstacle.

🎥 Watch the Game in Action

🔗 GitHub Repository

You can explore the full source code in my GitHub repo below:

👉 GitHub - Endless Runner Game using PyGame & Amazon Q CLI

Feel free to ⭐ star the repo or fork it to try your own version!


🎯 Learnings & Takeaways

  • Amazon Q CLI is really a very useful and cool tool for developers to build anything in minutes.

  • I Understood how endless runner games work—jump physics, obstacle spawning, speed scaling, and collision detection.

  • Learned to integrate sound effects and visuals to make the game more immersive and engaging.

  • Gained practical experience in using PyGame for handling graphics, events, and game loops.


Conclusion

I was a fun building a game using AmazonQ CLI and exploring game development.
It showed me how we can use AI for developemt by leaving space for creativity too..
Whether you're a beginner or experienced developer, I highly recommend giving Amazon Q CLI a try for your next creative coding idea.


🤝 Connect with Me

DevCycle image

Fast, Flexible Releases with OpenFeature Built-in

Ship faster on the first feature management platform with OpenFeature built-in to all of our open source SDKs.

Start shipping

Top comments (0)

Tiger Data image

🐯 🚀 Timescale is now TigerData: Building the Modern PostgreSQL for the Analytical and Agentic Era

We’ve quietly evolved from a time-series database into the modern PostgreSQL for today’s and tomorrow’s computing, built for performance, scale, and the agentic future.

So we’re changing our name: from Timescale to TigerData. Not to change who we are, but to reflect who we’ve become. TigerData is bold, fast, and built to power the next era of software.

Read more

👋 Kindness is contagious

Explore this insightful piece, celebrated by the caring DEV Community. Programmers from all walks of life are invited to contribute and expand our shared wisdom.

A simple "thank you" can make someone’s day—leave your kudos in the comments below!

On DEV, spreading knowledge paves the way and fortifies our camaraderie. Found this helpful? A brief note of appreciation to the author truly matters.

Let’s Go!