Star Wars Galaga A twist on an arcade classic
View on GitHub

Star Wars Galaga was created in my senior year at CSUB as a group project for the Software Engineering course. The coding phase of this project lasted just under one month and consisted of over 100 commits between three developers. My responsibilities for this project included collision detection, input handling, graphic rendering, and enemy AI. In addition to using Git/GitHub in a group setting and exploring new software libraries such as GLFW and GLib, we also gained experience with remote collaboration. Although our diverse locations included on-campus, in nearby cities, and even the other side of the country, by dividing tasks between us and heavily utilizing email and GitHub to stay connected, we ended up creating a great product.

GLFW & GLib
The best things in life are free

Much of the heavy lifting in our game was offloaded to GLFW and GLib, a pair of excellent open-source libraries.

GLFW is used to manage the main event loop and handle input within the application. Using this library enabled an asyncronous callback-oriented approach to event handling, rather than writing an event loop from scratch where all input is handled every frame. This approach allows for cleaner code more typical of object-oriented event-driven programs, despite it being written in pure C.

Gnome's GLib project is used primarily for its robust and generic data type implementations. This was my first project using GLib, as I had previously coded basic data structures from scratch. I noticed the need for linked lists of several types of structs as I was coding: lasers, ships, turrets, and the like. However, I had been embedding next pointers within each type of struct, so I couldn't just use the same functions for adding, deleting, iterating, etc. on the lists. As I started considering coding a more generic linked list which could handle this, I realized that my NIH Syndrome was showing and decided on GLib's implementation, since I'd heard good things about the library. Not only does this provide stable and flexible data types, but GLib also provides convenience functions such as g_list_foreach() to easily operate on the entire list.

Enemy AI
"Exterminate!"

The behaviors for enemy ships and lasers were the most interesting parts of this game to design and implement. As levels are beaten, the difficulty is increased by adding new behaviors to enemies and making their existing actions more precise. This goes a step further than simply making opponents faster, stronger, or tougher. Some enemies will attempt to follow you, while others will more aggressively target your ship. Over time, enemies become progressively better at dodging your lasers as they find a path through your offense. At higher levels, homing lasers curve towards your current position (nevermind the impossible physics involved). The Death Star at the top of the screen will intermittently fire a powerful wide beam towards the player.

While some of these techniques are potentially lethal, others are more psychological warfare than actual threats, such as bombarding players with weak homing lasers to intimidate them to dodge into more powerful lasers nearby. Behaviors like this increase the difficulty by making the player nervous rather than increasing the actual danger, lending to a fair and engaging difficulty curve rather than mere frustration.