GameBanana shows no ads to members. Sign up now!
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()
{
++FreedAnimals
base.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()
{
	if (DEBUG_DISABLE_HUD)
		return

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

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

	base.RenderHUD()
}

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 tou can change baseX and 0x38 to other X and Y positions.

And now it's there!


It even works!


If you have any questions, feel free to ask!
Sign up to access this!

Embed

Share banner
Image URL
HTML embed code
BB embed code
Markdown embed code

Announcement

Enjoy!
- Lave sIime

Credits

Key Authors
Lave sIime avatar Team Flame Quest Flag
Affiliation
Team Flame Quest
Lave sIime username pic Joined 4mo ago
Cybershell Mode
Team Flame Quest Flag Affiliation: Team Flame Quest
5,869 points Ranked 1,210th
18 medals 1 legendary 2 rare
  • Submitted 50 Gamefiles Medal icon
  • Submitted 20 Gamefiles Medal icon
  • 10 submissions featured Medal icon
  • Submitted 5 Gamefiles Medal icon
  • Submission featured Medal icon
  • Reached 1,000 Points Medal icon
Writing the tutorial

Submitter

Lave sIime avatar
Lave sIime username pic Joined 4mo ago
Cybershell Mode
Team Flame Quest Flag Affiliation: Team Flame Quest
5,869 points Ranked 1,210th
18 medals 1 legendary 2 rare
  • Submitted 50 Gamefiles Medal icon
  • Submitted 20 Gamefiles Medal icon
  • 10 submissions featured Medal icon
  • Submitted 5 Gamefiles Medal icon
  • Submission featured Medal icon
  • Reached 1,000 Points Medal icon
Lave sIime avatar
Lave sIime
Team Flame Quest Flag
Affiliation
Team Flame Quest

Creator
Sign up to access this!
Sign up to access this!
Sign up to access this!

Game

Sign up to access this!

Category

Details

Difficulty Level
Advanced

Attributes

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • Today's Pick
    Featured on Sep 2 2020
  • 5
  • 1.2k
  • 3
  • 26d
  • 24d

More from Submitter

More Script Modding Tutorials