AWS Logo
Menu
๐Ÿง™โ€โ™‚๏ธ Build a Dark Fantasy RPG in Python with Amazon Q CLI

๐Ÿง™โ€โ™‚๏ธ Build a Dark Fantasy RPG in Python with Amazon Q CLI

Built a 2D RPG in Python with Amazon Q CLI! See how AI-assisted development turned a fun project into a powerful game dev learning experience.

Published May 31, 2025

๐ŸŽฎ Game Overview: Dark Fantasy Game

Dark Fantasy Game is a single-player, 2D, offline RPG mini-game set in a grim, medieval fantasy world. You play as a lone warrior battling waves of enemies โ€” mostly goblins โ€” in a side-scrolling environment. Despite its simplicity, the game includes all the basic elements of an RPG:

๐Ÿ”น Core Features:

  • Player Control: Move the character using arrow keys.
  • Combat System: Press spacebar to attack nearby enemies.
  • Enemy AI: Goblins chase the player and attack on sight.
  • Stats Tracking: Health points (HP), score, and game-over logic.
  • Sprite-Based Animation: Characters and enemies have walking, attacking, and death animations.
  • Basic Game Loop: Start screen, active gameplay, and game-over states.

๐Ÿงฑ Project Structure

dark-fantasy-game/
โ”œโ”€โ”€ assets/
โ”‚ โ””โ”€โ”€ sprites/
โ”‚ โ”œโ”€โ”€ player/
โ”‚ โ””โ”€โ”€ goblin/
โ”œโ”€โ”€ dark_fantasy_game.py
โ”œโ”€โ”€ game_stats.py
โ”œโ”€โ”€ enemy.py
โ”œโ”€โ”€ player.py
โ””โ”€โ”€ utils/
โ””โ”€โ”€ animation.py

โš™๏ธ Using Amazon Q CLI to Build the Game

Amazon Q CLI is an AI-powered assistant that can generate code directly from the terminal using natural language prompts. I used it extensively to bootstrap the game's foundation.

๐Ÿง Player Class Generation

aws q generate python \
--prompt "A player class in pygame that supports movement and attack animation" \
--output player.py

๐Ÿ‘น Enemy (Goblin) Class

aws q generate python \
--prompt "Create an Enemy class that chases the player and animates attacks in pygame" \
--output enemy.py

๐Ÿ“Š Stats Manager

aws q generate python \
--prompt "Create a StatsManager that tracks player health, score, and game over logic" \
--output game_stats.py

๐ŸŽž๏ธ Animation Utility

aws q generate python \
--prompt "A function that loads and plays sprite animations from a folder in pygame" \
--output animation.py
From there, I edited the generated code to fine-tune game mechanics, fix bugs, and add sound effects, collision logic, and enemy behavior.


๐Ÿ“š Key Lessons from the Project

โœ… 1. Amazon Q CLI greatly accelerated development

I was able to scaffold most of the gameโ€™s core structure in minutes using natural language prompts.

โœ… 2. Reinforced modular design thinking

Q CLI encouraged me to split logic into separate files and classes โ€” cleaner code, easier debugging, and better organization.

โœ… 3. Learned pygame through hands-on generation

Instead of reading documentation line by line, I learned by editing and testing code generated by Q CLI.

โœ… 4. AI wonโ€™t replace developers โ€” it enhances them

I still had to think through design, fix logic errors, and polish the game. Q CLI just helped me move faster.

๐Ÿ”— Watch & Explore

๐Ÿ“บ YouTube Demo:
https://youtu.be/hO-bxtUiYOQ
๐Ÿ’ป GitHub Source Code:
https://github.com/TrQuHuy/dark-fantasy-game

๐Ÿง  Final Thoughts

Dark Fantasy Game is not a commercial-grade product โ€” but itโ€™s a complete, functional, and enjoyable mini-game built almost entirely through an AI-assisted workflow.
If you're a Python learner, hobbyist game developer, or just curious about the power of Amazon Q CLI, I highly recommend trying this approach. All you need is an idea, a few terminal commands, and youโ€™re off creating your own game.
ย 

Comments