Background enemy shooting a bullet

I started a Game Boy game during the 2020 lockdown, when I found this article, explaining the basics of C Game Boy development. The Game Boy was my first video game console, and as I didn’t want to mess with ASM, this was the perfect opportunity. I won’t be describing how a Game Boy works, so if you’re curious, the best would be visiting the tutorial I linked above or this one. Understanding memory and displaying is pretty straightforward, and very interesting!

So I started as everybody would do, making a sprite move on screen.

Quickly, I decided that a simple shoot them up would be something fun to do, because platformers and RPGs are very common projects on the console. Soon, my butterfly character could shoot, lose life, drop bombs with bullet cancel, earn points when destroying enemies… and then I completely stopped, when scrolling became an issue. Lockdown was finished, and I moved on.

The game in 2020.

In 2022, I wanted to continue the project, and solved the scrolling issue. I’ve also added basic collision detection and also bought a GBxCart RW to be able to read and write on real cartridges. With an empty cartridge, I was able to test my game on real hardware on my Game Boys.

Now that I have invested a bit of time and money, I’m decided to finish the project for real. But I still stopped for a whole year…

…Until this week! I’m finally starting up again. I’ve obviously needed to dive into forgotten code and debug some things, which took a bit of time. After that, I set up a real pipeline. I use Visual Studio Code, with a Makefile that I can trigger inside from a shortcut, and the Emulicious debugger extension, to iterate more easily.

Next, the big step was to detect when enemies are on-screen, and making them able to shoot a bullet. You can see in the video below that it’s working.

0:00
/0:13

When I update the camera for scrolling, I check the new tiles appearing in the background layer. If it is an enemy tile, I register its settings (position, life, type, etc) in an array, then proceed to make it shoot regularly, by updating a global enemy bullet array.

To save up space for sprites, I’ve decided that enemies by default would be in the background layer, rather than as sprite. As you’ll see in the screenshot below, the first 4 sprites are dedicated to the playable character. The next 6 ones are for the player bullets. Then, the next 22 are for enemy bullets, and I have 8 left for moving enemies, big multi-sprites bosses, pickup items, etc. 22 bullets might be too much for a small screen like the Game Boy, but we’ll see. This could make some cool bullet hell scenes, like for the final boss. In reality, I’ll be perhaps more flexible with those numbers, and mix up more freely moving sprite enemies and static background enemies. At least with what I’m doing, I have different options!

The sprite memory.

Next time, the goal will be to make a real manager for both enemies and bullets. Enemies will need to be tracked, with different types and behaviors, their bullets too, with bullets going in different directions for each enemy (a simple / | \ pattern for example, for a start).

Hopefully this blog will motivate me to go on this adventure and make me progress on the game steadily!