Star Fighter

Personal

Project Type

Python, Pygame

Languages/Frameworks

Programmer, 2D Artist

Role(s)

May 8, 2021

Latest Release

Star Fighter is a 2D shoot ‘em up which tasks the player with shooting down endless hordes of enemies and dodging projectiles to gain a high score. The mechanics and aesthetics of the game take inspiration from 80s arcade games like Galaga and Defender, as well as modern titles like ZeroRanger.

In Detail

Star Fighter is a game that I wrote in Python with the help of the pygame framework. In addition to programming, I also designed and animated the art assets that you can see in game. Save for the music, which was composed by my talented friend YoItsRion, the endeavor was undertaken as a solo project meant to explore object-oriented programming, design patterns, and the Python language.

I started development in 2021 while I was following a KidsCanCode tutorial for making a simple shoot ‘em up using the pygame framework. The first version of the game was essentially a clone dressed with my own art assets and a few custom enemies.

Star Fighter - First VersionStar Fighter - First Version

Though the tutorial proved to be useful in learning the basics such as the game loop, rendering, and simple AI logic; I soon ran into a problem when I tried to add new enemies, logic, and scenes. The source code, at this point, did not observe the object-oriented paradigm so class relationships are vague, and some classes assumed other classes would not change. To make a long story short, the source code became such a rigid and tangled mess that adding new features required rewriting entire systems from scratch. There had to be a better way, and indeed I quickly found a solution to my problem - design patterns.

The State pattern was used the most as it fit the game loop perfectly - an abstract ‘State’ that had its data and behavior subdivided into handling input, processing updates, and displaying the output. This pattern solved the problem of data encapsulation, and separation of concerns while providing a common interface for the game loop.

After a couple of weeks of reworking the codebase, the addition of new features became straightforward. Thanks to the much more flexible codebase I was working with, the next update saw the addition of new enemy types, gameplay enhancements such as a scaling difficulty level, and an overhaul to the game’s graphics - including proper animation. The resulting game was more polished than ever before.

Star Fighter Intro ScreenStar Fighter Gameplay

I released the update on itch.io for Windows, and it was received quite well. Indeed, I even received my first fan mail from it which was really fulfilling. Other developers soon found that the game also works on Linux albeit with a few tweaks on the file handling, so I corrected the source code to use platform-agnostic code in response. It was also around that time that a writer for a UK-based magazine called Linux Format took interest in the game, and implemented a multiplayer component (using sockets - a low-level networking interface) which I did not even thought possible. The articles about this can be found on Linux Format (#282 and #283)

Looking back, there’s still some game design and code issues that could be improved. For example, the ‘triple gun’ powerup does not expire - a game design choice that was made as a bandaid for the game’s scaling difficulty. In retrospect, the game could have done without this as it made the game too easy on higher difficulties, and detracted from one of the main focus of the game - which is dodging projectiles. There were also issues in the UI and animation code which admittedly is difficult to read and reason about - some sections of the code, for example, were hardcoded and do not account for different screen sizes and orientations.

Nevertheless, Star Fighter ultimately became the project that gave me first-hand experience with implementing my learnings on object-oriented principles, design patterns, and the ins and outs of the Python language. Up until that point, these concepts were merely theoretical knowledge that I have had not the opportunity to translate into concrete applications. Star Fighter basically was the opportunity to apply those things, and for that, it rightfully serves as the first milestone for my nascent software engineering career.

Posted on Tue Apr 16 2024