This is a submission for the Amazon Q Developer "Quack The Code" Challenge: That's Entertainment!
What I Built
Pac-Ghost turns the classic maze into a battle-royale: you're the blue ghost competing against nine colorful AI ghosts.
You must level up "eating/killing" the random PacMan's that appears in the maze. When you kill a PacMan in the maze you will level up; if your level is higher than other ghosts level, you can kill them too; if your level is the same as other ghost, both are killed.
Win who is the last ghost stand in the maze.
Demo and Code Repository
Use Python and PyGame to run it, fly to:
https://github.com/fabiocore/pac-ghost
How I Used Amazon Q Developer
In the project's directory I've created a file called GAME.md and used the feature of 'Context management and profiles' of Amazon Q (https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-context-profiles.html) to add the file.
The GAME.md file has some guidance for the Amazon Q on what is the project is, about the game, how I would like the game to be and other things like mechanics, look and feel and etc.
1st PROMPT
Let's create a new Game using PyGame.
Use the context(GAME.md file) to understand what we will gonna build.
Plan first, Think step by step, think hard.
The response from Amazon Q was:
-- Response for the #1 PROMPT
I'll help you create the Pac-Ghost game using PyGame based on the information in the GAME.md file. Let's plan this step by step.
Game Planning for Pac-Ghost
1. Game Overview
Pac-Ghost is a battle-royale style maze game where:
• 10 ghosts (1 player, 9 AI) compete to be the last one standing
• Ghosts level up by consuming stationary PacMan characters
• Higher level ghosts can eliminate lower level ones
• Equal level ghosts eliminate each other
2. Core Components
A. Game Structure
- Main game loop
- State management (menu, gameplay, game over)
- Rendering system
- Input handling
- Collision detection
B. Game Elements
- Maze generation
- Ghost entities (player and AI)
- PacMan spawning system
- Level and speed progression
- Collision rules implementation
3. Implementation Plan
Let's break down our implementation into manageable steps:
Project Setup
• Create directory structure
• Initialize PyGame
• Set up basic game loopMaze Generation
• Procedural maze generator (25-35 tiles square)
• Ensure at least 60% walkable area
• Add warp tunnels on edgesEntity Creation
• Ghost class (player and AI)
• PacMan class
• Level and speed attributesGame Mechanics
• Movement system (grid-locked with tweening)
• PacMan spawning timer
• Collision detection and rules
• Level progressionAI Implementation
• Pathfinding with A*
• Decision making (target PacMan or weaker ghosts)
• Movement executionGraphics and UI
• Ghost sprites with level indicators
• PacMan sprites
• Maze rendering
• Death animation effectsAudio System
• Sound effects for pickups
• Sound effects for ghost eliminationsGame States
• Main menu
• Gameplay
• Spectator mode
• Victory/defeat screen
4. File Structure
Let's organize our project with this file structure:
pac-ghost/
├── main.py # Entry point
├── game/
│ ├── init.py
│ ├── constants.py # Game constants
│ ├── game.py # Main game class
│ ├── maze.py # Maze generation
│ ├── entities/
│ │ ├── init.py
│ │ ├── ghost.py # Ghost class
│ │ └── pacman.py # PacMan class
│ ├── ai/
│ │ ├── init.py
│ │ └── pathfinding.py # A* implementation
│ └── ui/
│ ├── init.py
│ ├── menu.py # Menu screens
│ └── hud.py # In-game UI
├── assets/
│ ├── images/
│ │ ├── ghost.svg
│ │ ├── ghost-colors.svg
│ │ ├── pacman.svg
│ │ └── death-effect.svg
│ └── sounds/
│ ├── pickup.wav
│ └── elimination.wav
└── utils/
├── init.py
└── helpers.py # Utility functions
5. Implementation Details
Let's start by creating the core files for our game. I'll begin with the main entry point and the basic game structure.
After some time waiting Amazon Q developing the game, I got the first working version of the game, with some issues that I ask it to solve, so iterate with my second prompt.
2nd PROMPT
OK, I guess we are almost there, but we need to fix some things.
- The level is not visible, although I can see it, is kind inside the ghost image and the lvl is not easy to read.
- The IA ghosts are cheating, they kill me passing through the walls without respecting the maze walls.
- I was able to kill another ghost in the same level as me, If the ghosts are in the same level, both got killed.
- I would like the game looking and feel like the original classic PacMan with black background and blue walls like 1980 game.
After the second iteration, the ghosts are still cheating, but the speed was better.
3rd PROMPT
ok, for some reason the ghosts are still cheating. I saw them ignoring the maze walls. Besides that, when they are 'cheating' the also increase their own speed at insane speed!
The speed should be equal at start, and only when a ghost level up it gots a little bit more speed, not much.
Also, I got the below error in the console(although the game is working)
:488: RuntimeWarning: Your system is avx2 capable but pygame was not built with support for it. The performance of some of your blits could be adversely affected. Consider enabling compile time detection with environment variables like PYGAME_DETECT_AVX2=1 if you are compiling without cross compilation.
pygame 2.5.2 (SDL 2.30.0, Python 3.12.3)
Hello from the pygame community. https://www.pygame.org/contribute.html
Could not load sound file: pickup.wav, error: RIFF form type is not WAVE (not a Waveform file)
Could not load sound file: elimination.wav, error: RIFF form type is not WAVE (not a Waveform file)
Now the ghost are better, but still cheating for some reason. I guess the machines find out its way to break the rules too. :D
But I'm satisfied with the current version of the game and perhaps I'll iterate more on the future and add some features.
That's all! Thank you!
Top comments (3)
Really creative combining 2 genres of games from 2 different eras!
Thank you :)
Amazing idea and how we handle to build the game with Q dev and the prompt interactions