
Posted on
Building Pacman Game with #AmazonQDeveloperCLI
Building Pacman Game with Amazon Q Developer CLI
The exercise is on this
github.com/Oghenesuvwe-dev/PacMan-game-with-pygame-and-amazonqdevelopercli repository
After installation and aws configure of the #AmazonQDeveloperCLI
as on the installation doc link below.
docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html?.
I started with these steps below.
Step 1
Project Setup
Prompt:
"Initialize a new Python project for a Pacman game using Pygame. Create a folder structure with src, assets, and tests directories."
Install Dependencies
Prompt:
"Installing Pygame in the project environment."
Got the confirmation:
import pygame; print('Pygame installed successfully')
Greeted with/and
Hello from the pygame community, pygame.org/contribute
Step 2
Basic Game Window
Prompt:
"Write code to create a Pygame window titled 'Pacman' with a black background."
Maze Creation
Prompt:
"Generate a 2D array representing the Pacman maze layout."
Prompt: "Draw the maze walls and paths on the screen using Pygame rectangles."
Running the game with
"parallels@parallels-Parallels-Virtual-Platform:~$ cd ~/Desktop/pacman-game && python3 main.py"
Pacman game is on!.
Step 3
Pacman Character
Prompt:
"Create a Pacman sprite that can move in four directions with keyboard input."
Pacman game Newly improved!.
Ghost Implementation
Prompt:
"Add ghost sprites with basic movement logic."
Prompt: "Implement simple AI for ghosts to chase Pacman."
Pellets and Scoring System
Prompt:
"Place pellets throughout the maze and increase score when Pacman eats them."
Game Logic Implementation
Prompt:
"Detect collisions between Pacman, ghosts, and pellets.
"
Prompt:
"End the game if Pacman collides with a ghost."
The game now includes
1, Pellets & Scoring.
2, White pellets placed throughout the maze (value 2 in maze array).
3, Score increases by 10 points when Pacman eats a pellet.
4, Score displayed in top-left corner.
Collision Detection:
5, Pellet collision: Removes pellets when Pacman touches them.
6, Ghost collision: Ends game when Pacman gets too close to any ghost (distance < 25 pixels).
Game Logic:
7, Game over state when Pacman hits a ghost.
8, Press R to restart after game over.
9, Game continues until collision occurs.
User Interface Enhancement
Prompt:
"Display the current score and lives remaining on the screen."
Testing Implementation
Prompt:
"Write unit tests for Pacman movement and collision detection."
Testing fixes applied:
- Removing the problematic WAV files from the assets/sounds directory
- Simplifying the sound generation to create a single reliable beep sound
- Using the same beep sound for all game events (chomp, death, start)
Polish Phase
Prompt:
"Add sound effects and improve graphics for Pacman and ghosts.
Prompt:
"Implement a start screen and game over screen."
Polish Added: Sound Effects, Improved Graphics, Game Screens Improvements but the sound was not working.
Which brought Pacman-game to the image below...
The start Screen above and the main game screen below
Run and Debug
Prompt:
"Run the game and debug any issues found during playtesting."
Issues identified:
Improvement fixes:
- Adding pause functionality and fixing ghost speed
- Adding win condition when all pellets are collected.
Debugging fixes:
1, Fixing pellet collision detection to prevent multiple sounds when standing on a pellet
Agentic AI Prompts Used:
1 "Generate Pygame code for a Pacman character that moves with arrow keys."
2 "Create a function to draw a maze from a 2D list."
3 "Implement ghost AI that follows Pacman."
4 "Write code to detect when Pacman eats a pellet and update the score."
5 "Add a game over screen when Pacman is caught by a ghost."
This demonstrates effective use of Amazon Q Developer for building classic games through incremental development and targeted AI assistance.
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse