DEV Community

Cover image for Build Games with Amazon Q CLI! πŸ†πŸ‘•
Milan Patel
Milan Patel

Posted on • Edited on

Build Games with Amazon Q CLI! πŸ†πŸ‘•

Building Shadow Link: My Journey with Amazon Q CLI Game Development Challenge

Github repo

Introduction

When I stumbled upon the "Build Games with Amazon Q CLI" contest, I knew I had to participate. As someone passionate about game development and always eager to explore new AI tools, this was the perfect opportunity to combine both interests. In this blog post, I'll share my experience developing "Shadow Link" - a unique 2D platformer that challenges players to think in parallel dimensions.

The Initial Spark

The idea for Shadow Link came from a simple yet intriguing concept: what if you had to control two characters simultaneously, where one's movement directly affects the other in opposite ways? This mechanic, while simple to understand, opens up a world of complex puzzle-solving possibilities.

Development Journey with Amazon Q CLI

Starting Point

I began with a clear prompt to Amazon Q CLI:

amazonq generate project \
  --description "Build a unique Pygame-based 2D game called 'Shadow Link'. In this puzzle-platformer, players control two linked characters in parallel dimensions. Moving one character affects the other in inverse ways. Each level requires strategic positioning, shadow mechanics, and physics puzzles. Use Pygame for graphics, collision, and input. Include a level editor, save/load system using JSON, and scalable level design architecture. Keep the code modular and well-commented." \
  --language python \
  --framework pygame \
  --include-readme true \
  --include-tests false
Enter fullscreen mode Exit fullscreen mode

This initial prompt gave me a solid foundation to build upon. Amazon Q CLI helped generate the basic project structure, but the real magic happened in the iterative development process.

Technical Stack

  • Python 3.x: For the core game logic
  • Pygame 2.5.2: Handling graphics, input, and physics
  • Amazon Q CLI: For code generation and debugging assistance

Project Structure

The game follows a modular design pattern:

shadow-link/
β”œβ”€β”€ main.py              # Game entry point
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ game.py         # Main game logic
β”‚   β”œβ”€β”€ player.py       # Player character mechanics
β”‚   β”œβ”€β”€ level.py        # Level management
β”‚   β”œβ”€β”€ level_editor.py # In-game level editor
β”‚   └── constants.py    # Game settings
β”œβ”€β”€ assets/             # Game resources
└── levels/            # Level data
Enter fullscreen mode Exit fullscreen mode

Game Features

Core Mechanics

  1. Dual Character Control

    • Control two characters simultaneously
    • Mirror movement mechanics
    • Strategic positioning requirements
  2. Level Editor

    • Create custom levels
    • Save and load functionality
    • Intuitive platform placement
  3. User Interface

    • Clean, minimal design
    • Intuitive controls
    • Clear visual feedback

How to Play

Controls

  • Movement: LEFT/RIGHT arrow keys
  • Jump: UP arrow key
  • Pause: ESC
  • Reset: R
  • Level Editor: E (from main menu)

Objectives

  • Guide the blue character to the red exit
  • Guide the purple shadow character to the purple exit
  • Master the mirroring mechanics to solve puzzles

Development Challenges and Solutions

Challenge 1: Character Synchronization

The biggest challenge was implementing the mirroring mechanics between the two characters. Amazon Q CLI helped me debug the physics calculations and ensure smooth character movement.

Challenge 2: Level Editor Implementation

Creating an intuitive level editor required careful consideration of user experience. Amazon Q CLI assisted in generating the basic structure, which I then refined for better usability.
Absolutely! Here’s a section you can add to your blog post, describing the screenshot and how you interacted with Amazon Q CLI using prompts. This will help readers visualize your workflow and understand how you leveraged AI assistance in your development process.


Using Amazon Q CLI: My Interactive Coding Experience

One of the most exciting aspects of this project was working directly with Amazon Q CLI in an interactive terminal environment. The screenshot below captures a moment from my development journey:
Image description

![Amazon Q CLI Interactive Session]
![Image description][https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1p27vyxf5yxq7xicvw6h.png)]

In this session, you can see how I initiated a chat with Amazon Q CLI by simply typing:

q chat
Enter fullscreen mode Exit fullscreen mode

This brought up the Amazon Q CLI interface, where I could start giving prompts and receive real-time coding assistance. For example, I asked:

"Can you run the game which is in folder pygame_game shadow one?"

Amazon Q CLI responded by helping me check if the folder existed and guiding me through the process of running the game. This interactive, conversational approach made it incredibly easy to troubleshoot issues, get code suggestions, and even modify files on the fly.

Prompt-Driven Development

Throughout the development of Shadow Link, I used prompts like:

  • How to win this game?
  • Make it easy to win
  • Fix character movement so they can't leave the screen Image description

Amazon Q CLI would not only provide step-by-step instructions but also directly edit my code when needed. For instance, when I encountered an issue where the character could leave the screen boundaries, I described the problem in plain English, and Amazon Q CLI generated the necessary code changes to fix it.

This prompt-driven workflow allowed me to focus on game design and logic, while Amazon Q CLI handled much of the boilerplate and debugging. It truly felt like pair programming with an AI assistant!

Future Enhancements

  1. Gameplay

    • Additional levels with increasing difficulty
    • New mechanics like switches and moving platforms
    • Character animations and improved graphics
  2. Technical

    • Sound effects and background music
    • Level selection menu
    • Performance optimizations

Conclusion

Developing Shadow Link with Amazon Q CLI was an enlightening experience. The AI assistant not only helped with code generation but also provided valuable insights during debugging and optimization. This project demonstrates how AI tools can enhance the game development process while maintaining creative control.

Resources

Installation

# Install dependencies
pip install pygame

# Clone the repository
git clone https://github.com/MilanPatel2003/shadow-link.git
cd shadow-link

# Run the game
python main.py
Enter fullscreen mode Exit fullscreen mode

Note: This game was developed as part of the "Build Games with Amazon Q CLI" contest. The development process was significantly enhanced by the AI assistance provided by Amazon Q CLI, which helped with code generation, debugging, and game design improvements.

Top comments (0)