Building a 2D Shooting Game using Amazon Q Developer and generative AI
I create a 2D action shooting game using Amazon Q Developer. In this post, I'll share my experience building this game with multiple levels, character animations, and enemy AI.
Published Nov 3, 2024
The game features a soldier fighting against waves of zombies across three increasingly difficult levels. Players must survive while killing a specific number of enemies to progress:
Level 1: Kill 25 zombies (slower enemies, single shot)
Level 2: Kill 50 zombies (normal speed, triple shot)
Level3: Kill 100 zombies(faster enemies, arc shot)
- Player character with multiple animation states:
- Walking animation (7 frames)
- Shooting animation (4 frames)
- Reloading animation (13 frames)
- Hurt animation (3 frames)
- Death animation (4 frames)
- Ammo system with reloading mechanics
- Health system with damage feedback
- Three different weapon types based on level
- Zombie enemies with walking and attack animations
- Smart pathfinding towards player
- Different speeds based on level
- Attack animations when close to player
- Multiple spawn points around the screen
Each level features a unique weapon system:
The game uses sprite sheets for all animations. Here's how we handle character animations:
We implemented precise collision detection using scaled hitboxes:
One of the biggest challenges was managing multiple animation states (walking, shooting, reloading, hurt, death) and ensuring smooth transitions between them. We solved this by creating a priority system where certain animations (like death) would override others.
Making enemies move naturally and attack at appropriate distances required careful tuning:
We implemented a level transition system that:* Clears all enemies* Shows completion message* Updates weapon systems* Adjusts enemy spawn rates and speeds
Potential enhancements could include:
- Power-up system
- More enemy types
- Boss battles
- Score system
- Sound effects and background music
Building this game taught valuable lessons about:* Game state management* Animation systems* Collision detection* Enemy AI* Level progression mechanicsThe modular code structure allows for easy additions and modifications, making it a great foundation for further development.The complete source code demonstrates how to create a complex game with multiple systems working together while maintaining clean, organized code structure.