
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
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.
- Python 3.11
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
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.
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.
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.
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.
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
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
โโโ main.py
โโโ assets/
โ โโโ player.png
โ โโโ virus.png
โ โโโ mask.png
โ โโโ sanitizer.png
โ โโโ background.jpg
โ โโโ sounds/
โ โโโ powerup.wav
โ โโโ gameover.wav
โ โโโ bgm.mp3
โโโ README.md
StagePrompt๐งฑ Basic Setup
Create 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.
- ๐งฐ 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.
๐ผ๏ธ YouTube โ Avoid the Virus
- ๐ผ๏ธ Custom sprite art (replacing placeholder rectangles)
- ๐๏ธ Difficulty scaling (faster virus spawns over time)
- ๐ Leaderboard for high scores
- ๐ฑ Mobile adaptation using Kivy or Unity
"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. ๐น๏ธ
- Install Pygame:
pip install
pygame- Start your own AI-prompted dev session:
q chat
Happy coding and game building!
ย
ย