Ads keep us online. Without them, we wouldn't exist. We don't have paywalls or sell mods - we never will. But every month we have large bills and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3

How to add custom HUD elements - A Tutorial for Sonic 3 A.I.R.

This tutorial will cover adding custom HUD elements to Sonic 3 AIR. Shall we get started?

First, you'll need to know what you want to do. This step can be the hardest, or it can be the easiest. For this example, I'll be showing how to add an animals freed counter.

Once you have an idea, you'll want a way to make a variable for the number that you want to display. For this example, I want to show how many animals were freed, so I'll make a variable named "FreedAnimals". Address locations also work, so you can use u8[0xfffffe18] if you want to display a continue counter.

global u8 FreedAnimals

Next, I'll need a way to have the variable change, so I'll add ++FreedAnimals to the animals init code.

//# address-hook(0x02c8b8) end(0x02c9d4)
function void fn02c8b8()

I used base. so that I don't have to copy-paste the entire function. It also allows compatibility with other mods. The next step is putting the HUD itself in.

//# address-hook(0x00db44) end(0x00dbb2)
function void RenderHUD()

	s16 baseX = global.level_started
	if (baseX < 0)
		baseX += 8
		global.level_started = baseX
	baseX += 0x0f

	bool isBonusStage = ( >= 0x13 && <= 0x15)
	if (!debug_mode.state)
		if (!isBonusStage)
			HUD.drawSprite("(YourHUDKeyGoesHere)", baseX, 0x38 , 0xe000)
			HUD.drawNumber("hud_digit_%d", FreedAnimals, baseX + 0x58, 0x38, 0xe000)


Needless to say, you should replace (YourHUDKeyGoesHere) with your sprite key for the HUD and FreedAnimals with your variable. This has the X and Y position of it be below the normal HUD, but you can change baseX and 0x38 to other X and Y positions. If you want, you can just use normal numbers instead of baseX, but baseX allows the HUD to move in after the intro instead of just appearing.

And now it's there!

It even works!

If you have any questions, feel free to ask!