py-Invaders


So I decided to give pygame a try. Having only ever used Unity and C# to for any of my previous projects, I found the simplicity of pygame refreshing and very fun to use. My code is by no means a masterpiece, but pygame allows for speedy speedy development, which makes the experience all the more enjoyable. 

There is a learning curve when using pygame for the first time, as is true with any new tool, but a simple game can quickly be made with an understanding of python classes and pygame's sprite system. I was able to make this small Space Invaders clone with only 3 main classes which inherited from pygame's Sprite class: Player(), Enemy() and Bullet() class, which I think are self explanatory. I also used a class to hold the game state as well as some values which needed to be tracked throughout gameplay. The core game loop is rather simple (its Space Invaders). Before each level starts, a set of enemies is generated in their respective positions, with a movement speed and fire-rate set in accordance with the game's level. The number of enemies, movement speed and fire-rate increase as the levels increase. The fire-rate for each enemy is random and determined by a random integer generated each frame. Text placement can be a bit tricky and convoluted in pygame, though this is the downside of not having a dedicated editor. On the upside, it allows you to get the core gameplay elements up and working without getting bogged down in a complicated editor environment.

Overall, using pygame was very enjoyable. I don't think I will completely switch over from Unity and C#, as I do enjoy working in C#. But for small prototype projects like py-Invaders, I think pygame is perfect and very rewarding. If ever you needed a reason to try pygame out, a small project like a Space Invaders clone is a perfect way to get started.

Leave a comment

Log in with itch.io to leave a comment.