Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Building Pacman Game with #AmazonQDeveloperCLI
Suvwe
Suvwe

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

Pacman game is on!.


Step 3
Pacman Character
Prompt: 
"Create a Pacman sprite that can move in four directions with keyboard input."

PACMAN1

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."

PACMAN1
Improved!


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:

  1. Removing the problematic WAV files from the assets/sounds directory
  2. Simplifying the sound generation to create a single reliable beep sound
  3. 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...

START PACMAN


The start Screen above and the main game screen below

PLAY PACMAN


Run and Debug
Prompt: 
"Run the game and debug any issues found during playtesting."
Issues identified:
Improvement fixes:

  1. Adding pause functionality and fixing ghost speed
  2. 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)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Location
    Nigeria
  • Education
    Hagital Consultant
  • Pronouns
    He?him
  • Work
    Cloud Solution Architect.
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp