AWS Logo
Menu
Avoid the Virus: Survival Arcade Game with Amazon Q & Pygame

Avoid the Virus: Survival Arcade Game with Amazon Q & Pygame

Build a fun survival arcade game using Python, Pygame, and Amazon Q AI. Dodge viruses, collect power-ups, and check the full code on GitHub!

Published Jun 1, 2025

๐ŸŽฎ Introduction

It started with a simple idea: what if we built a survival arcade game where a small character dodges waves of incoming viruses? Powered by curiosity and the newly released Amazon Q Developer CLI, we created "Avoid the Virus", a Python-based Pygame survival game that tests reflexes, timing, and a bit of luck.
Using Amazon Q's generative AI capabilities, we iteratively built the game, starting from a single prompt and evolving it into a fully playable experience โ€” complete with power-ups, sound effects, and a city-themed backdrop.

โš™๏ธ Tech Stack


๐Ÿง  Starting with AI-Powered Game Generation

We kicked things off using this prompt in Amazon Q Developer CLI:
Create a complete game using Python and Pygame called "Avoid the Virus".
That alone set up the foundation โ€” a main game loop, a player-controlled character, and virus-like enemies that home in on the player. With a few refinements and additional prompts, the AI helped scaffold out features like:
  • Virus enemy generation
  • Player movement using arrow keys
  • Collision detection and game-over logic

๐Ÿ›ก๏ธ Adding Power-Ups and Gameplay Depth

To make the gameplay more exciting and strategic, we added two types of power-ups:
  • ๐ŸŸฆ Mask โ€“ Grants 5 seconds of immunity.
  • ๐ŸŸจ Hand Sanitizer โ€“ Instantly destroys all viruses on screen.

Prompts used:

Add a power-up in the shape of a blue mask that makes the player immune for 5 seconds.
Add another power-up: a yellow hand sanitizer that removes all viruses on screen when picked up.
These additions were surprisingly easy to integrate using Amazon Qโ€™s step-by-step output and Pygame classes.

โฑ๏ธ Score & Survival Mechanics

Every second counts! The game tracks how long you can survive, with the score tied directly to time. Youโ€™ll find yourself dodging, grabbing power-ups, and getting better with each run.

Prompt used:

Add a survival timer and display the score in the top-left corner.
And voilร  โ€” a sleek timer and live score appeared on the screen, updating in real-time.

๐Ÿ™๏ธ Game Feel & Visuals

To boost immersion, we incorporated:
  • City street/hospital-themed background
  • Simple sprite-based visuals using placeholder rectangles (for now)
  • Sound effects for picking up power-ups and the dreaded game over

Folder Structure

avoid_the_virus_game/
โ”œโ”€โ”€ main.py
โ”œโ”€โ”€ assets/
โ”‚ โ”œโ”€โ”€ player.png
โ”‚ โ”œโ”€โ”€ virus.png
โ”‚ โ”œโ”€โ”€ mask.png
โ”‚ โ”œโ”€โ”€ sanitizer.png
โ”‚ โ”œโ”€โ”€ background.jpg
โ”‚ โ””โ”€โ”€ sounds/
โ”‚ โ”œโ”€โ”€ powerup.wav
โ”‚ โ”œโ”€โ”€ gameover.wav
โ”‚ โ””โ”€โ”€ bgm.mp3
โ””โ”€โ”€ README.md

๐Ÿ” Our Prompt Workflow (Simplified)

StagePrompt๐Ÿงฑ Basic SetupCreate a Pygame arcade game called "Avoid the Virus".โšก Add Power-UpsAdd a blue mask power-up that gives 5 seconds of immunity.๐ŸงŸ Enemy BehaviorMake virus enemies move from all directions toward the player.๐Ÿ•“ Score/TimerDisplay the player's survival time as a score.๐Ÿ”Š SoundsPlay a sound when the player picks up a power-up and another when the game ends.

๐Ÿ’ก What We Learned

  • ๐Ÿงฐ Amazon Q CLI is an incredibly efficient way to bootstrap and iterate game mechanics.
  • โœ๏ธ Prompt-driven development helps you stay in creative flow โ€” you focus on ideas, not syntax.
  • ๐ŸŽฎ Even simple games benefit from thoughtful power-up mechanics and sound design.
  • ๐Ÿ Pygame remains a fun, beginner-friendly tool for building 2D games fast.

๐Ÿ“ Repo


๐Ÿš€ Whatโ€™s Next?

  • ๐Ÿ–ผ๏ธ Custom sprite art (replacing placeholder rectangles)
  • ๐ŸŽš๏ธ Difficulty scaling (faster virus spawns over time)
  • ๐Ÿ† Leaderboard for high scores
  • ๐Ÿ“ฑ Mobile adaptation using Kivy or Unity

๐Ÿ™Œ Conclusion

"Avoid the Virus" was born from a simple idea and supercharged by Amazon Q CLI. The fusion of AI-assisted coding and an intuitive Python game engine like Pygame enabled rapid prototyping, fast iterations, and fun development.
We hope this inspires you to try building your own games.
With the right prompts, even beginners can make something amazing. ๐Ÿ•น๏ธ

โœ… Want to Try It Yourself?

  1. Install Pygame:
pip install pygame
  1. Start your own AI-prompted dev session:
q chat
Happy coding and game building!
ย 

Comments