DEV Community

GLJ
GLJ

Posted on

Building a Retro RoboCop Game Using Python and Amazon Q CLI

Building a Retro RoboCop Game Using Python and Amazon Q CLI

As part of the Amazon Q Developer CLI #BuildGamesChallenge, I created a side-scrolling shooter game inspired by the classic RoboCop arcade feel. I used Python, Pygame, and the Amazon Q CLI to design, build, and debug my game entirely through conversational development.

Why RoboCop?

I’ve always been drawn to retro side-scrolling shooters, and RoboCop seemed like the perfect inspiration. The iconic character, combined with a simple scrolling background and shooting mechanics, gave me a focused yet fun game idea to work on.

Tools I Used

  • Python 3 with Pygame – the game engine
  • Amazon Q Developer CLI – for help with generating code and learning game dev concepts
  • VS Code on WSL (Ubuntu) – my development environment
  • Git + GitHub – for version control and project sharing

How Amazon Q Helped

Effective Prompting Techniques

Instead of asking for entire chunks of code, I learned to:

  • Ask Amazon Q specific questions like "What is pygame.Rect and what parameters does it take?"
  • Request code snippets with explanations to understand why each part matters
  • Use it as a rubber duck debugger when things didn’t work as expected

AI Help with Classic Programming Challenges

Amazon Q helped me tackle:

  • Managing game loops and frame rates
  • Handling user inputs (pygame.event)
  • Drawing sprites and bullets on screen
  • Creating collision logic with Rect.colliderect()
  • Designing menus (pause screen and start screen) using semi-transparent overlays

Automation & Debugging

Some examples of where Q saved time:

  • Generating boilerplate for starting the game window
  • Auto-scaling my RoboCop PNG sprite
  • Explaining how to create multiple background layers for the scrolling effect
  • Troubleshooting why bullets weren't appearing (helped debug pygame.draw.rect() usage)

Game Features

Here’s what the final game currently includes:

  • Start screen with title, instructions, and control tips
  • RoboCop character rendered as a PNG sprite
  • Scrolling background that simulates forward movement
  • Spacebar shooting: fire red rectangular bullets from RoboCop
  • Enemy spawning from the right side of the screen at timed intervals
  • Collision detection between bullets and enemies
  • Score tracking
  • Pause screen with resume/exit options
  • ESC key to exit or return to main menu

Final Output

screenshot

Interesting Code Snippets

Bullet Firing & Movement

if event.key == pygame.K_SPACE:
    new_bullet = {
        "x": player_rect.x + player_rect.width,
        "y": player_rect.y + player_rect.height // 2 - 40,
        "rect": pygame.Rect(player_rect.x + player_rect.width, player_rect.y + player_rect.height // 2 - 40, 25, 5)
    }
    bullets.append(new_bullet)

# In game loop
for bullet in bullets[:]:
    bullet["x"] += bullet_speed
    bullet["rect"].x = bullet["x"]
    if bullet["x"] > SCREEN_WIDTH:
        bullets.remove(bullet)
# Enemy Spawning
enemy_spawn_timer += 1
if enemy_spawn_timer >= enemy_spawn_delay:
    enemy_y = player_rect.y
    new_enemy = {
        "x": SCREEN_WIDTH,
        "y": enemy_y,
        "rect": pygame.Rect(SCREEN_WIDTH, enemy_y, 50, 250)
    }
    enemies.append(new_enemy)
    enemy_spawn_timer = 0
# Collision Detection
for bullet in bullets[:]:
    for enemy in enemies[:]:
        if bullet["rect"].colliderect(enemy["rect"]):
            bullets.remove(bullet)
            enemies.remove(enemy)
            score += 10
            break
Enter fullscreen mode Exit fullscreen mode

What I Learned

  • Pygame basics: window creation, screen refresh, event handling
  • How game objects move in frames
  • How to manage sprites, background, and logic in a single loop

What's Next?

Some improvements and additions I’m thinking of:

  • Adding sound effects (shooting, enemy hit)
  • Creating a health bar and lives
  • Level-based difficulty
  • Better graphics/sprites (instead of rectangles for bullets/enemies)
  • Add an end screen (win or game over)

Final Thoughts

This project started small, but Amazon Q CLI made it easier to explore ideas without getting stuck. It wasn’t just about getting code written. It was about learning and problem-solving through conversation.

Instead of just Googling, I could talk to Amazon Q CLI and ask why things worked, not just how. That made this retro game building challenge one of the most educational and enjoyable projects I’ve worked on.

GitHub Repo: https://github.com/GLJ20/simple-robocop
Hashtags: #AmazonQDevCLI #BuildGamesChallenge

Top comments (0)