DEV Community

Cover image for ๐Ÿฆ  Avoid the Virus โ€“ Survive, Power Up, Repeat (Built with Amazon Q + Pygame)
Ageng Putra Pratama
Ageng Putra Pratama

Posted on

2 1 2 1 1

๐Ÿฆ  Avoid the Virus โ€“ Survive, Power Up, Repeat (Built with Amazon Q + Pygame)

๐ŸŽฎ 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.

Image description

โš™๏ธ 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".
Enter fullscreen mode Exit fullscreen mode

Image description

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.
Enter fullscreen mode Exit fullscreen mode
Add another power-up: a yellow hand sanitizer that removes all viruses on screen when picked up.
Enter fullscreen mode Exit fullscreen mode

These additions were surprisingly easy to integrate using Amazon Qโ€™s step-by-step output and Pygame classes.


Image description

โฑ๏ธ 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.
Enter fullscreen mode Exit fullscreen mode

Image description

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
Enter fullscreen mode Exit fullscreen mode

๐Ÿ” Our Prompt Workflow (Simplified)

Stage Prompt
๐Ÿงฑ Basic Setup Create a Pygame arcade game called "Avoid the Virus".
โšก Add Power-Ups Add a blue mask power-up that gives 5 seconds of immunity.
๐ŸงŸ Enemy Behavior Make virus enemies move from all directions toward the player.
๐Ÿ•“ Score/Timer Display the player's survival time as a score.
๐Ÿ”Š Sounds Play 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

๐Ÿ”— GitHub Repository โ€“ Avoid the Virus

๐Ÿ–ผ๏ธ YouTube โ€“ Avoid the Virus


๐Ÿš€ 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
Enter fullscreen mode Exit fullscreen mode
  1. Start your own AI-prompted dev session:
q chat
Enter fullscreen mode Exit fullscreen mode

Happy coding and game building!

Top comments (2)

Collapse
 
nathan_tarbert profile image
Nathan Tarbert โ€ข

pretty cool, love seeing how simple ideas just keep collecting new features - you think keeping things playful is what keeps momentum up on these projects or is it more about discipline?

Collapse
 
agengputrapratama profile image
Ageng Putra Pratama โ€ข

Thanks! ๐Ÿ™ I think it's a bit of both. Playfulness definitely helps spark creativity and keeps things exciting, especially in the early stages. But discipline is what turns a cool idea into something sustainable. Play gives momentum, but discipline gives direction. The sweet spot is probably switching between both depending on the phase of the project.

๐Ÿ‘‹ Kindness is contagious

Dive into this thoughtful piece, beloved in the supportive DEV Community. Coders of every background are invited to share and elevate our collective know-how.

A sincere "thank you" can brighten someone's dayโ€”leave your appreciation below!

On DEV, sharing knowledge smooths our journey and tightens our community bonds. Enjoyed this? A quick thank you to the author is hugely appreciated.

Okay