Path: blob/main/Scripts/Special/HUD.txt
1319 views
//--------------------Sonic CD HUD Script---------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5// Not all of these are used here in the HUD script, some are just used as a way for other objects to globally transmit values6#alias Object.Value0 : Object.UFOsCount // Initially set via a loop in the UFO script7#alias Object.Value1 : Object.TimeSeconds // Displayed time8#alias Object.Value2 : Object.TimeFrames // Hidden and used for time processing, this value is managed by Special Setup instead of here9#alias Object.Value3 : Object.Rings10#alias Object.Value4 : Object.LastUFOType // Used by UFOs for ring streak bonus11#alias Object.Value5 : Object.SpeedShoes // Used to transmit between player and UFO12#alias Object.Value6 : Object.BonusUFONo // "No" akin to Entity No, not as in "is there no UFO?"13#alias Object.Value7 : Object.WaterTimer // Used in making time deplete faster when wet1415// Game Mode Aliases16#alias 2 : MODE_TIMEATTACK1718// Priority19#alias 1 : PRIORITY_ACTIVE202122sub ObjectDraw23// Find the initial X Position to draw the HUD elements24TempValue1 = Screen.CenterX25TempValue1 -= 1282627// Draw the "UFO" graphic28DrawSpriteScreenXY(10, TempValue1, 10)2930// Draw the first digit of the UFOs counter31TempValue0 = Object.UFOsCount32TempValue0 /= 1033TempValue1 += 2434DrawSpriteScreenXY(TempValue0, TempValue1, 11)3536// Draw the second digit of the UFOs counter37TempValue0 = Object.UFOsCount38TempValue0 %= 1039TempValue1 += 840DrawSpriteScreenXY(TempValue0, TempValue1, 11)4142// Draw the "Time" Graphic43TempValue1 += 4844DrawSpriteScreenXY(11, TempValue1, 16)4546if Options.GameMode < MODE_TIMEATTACK47// In one of the normal game modes, where this object is the one keeping track of the time4849// First digit of time50TempValue0 = Object.TimeSeconds51TempValue0 /= 10052TempValue1 += 4053DrawSpriteScreenXY(TempValue0, TempValue1, 11)5455// Second digit of time56TempValue0 = Object.TimeSeconds57TempValue0 %= 10058TempValue0 /= 1059TempValue1 += 860DrawSpriteScreenXY(TempValue0, TempValue1, 11)6162// Last digit of time63TempValue0 = Object.TimeSeconds64TempValue0 %= 1065TempValue1 += 866DrawSpriteScreenXY(TempValue0, TempValue1, 11)6768TempValue1 += 6469else70// In Time Attack, where the global Stage.* variables are used for tracking time instead7172// First things first, cap the timer at half an hour73// That's quite a while... why are you still here?74// (Note - this wasn't in the initial version of the game, it came from a mobile update & Origins)75if Stage.Minutes > 2976Stage.Minutes = 3077Stage.Seconds = 078Stage.MilliSeconds = 079end if8081// Now, actually draw the number8283// First draw the minutes84TempValue1 += 4085DrawNumbers(0, TempValue1, 11, Stage.Minutes, 2, 8, 1)8687// Then draw the seconds tick88TempValue1 += 889DrawSpriteScreenXY(13, TempValue1, 11)9091// And draw the following seconds92TempValue1 += 1693DrawNumbers(0, TempValue1, 11, Stage.Seconds, 2, 8, 1)9495// Then draw the milliseconds tick96TempValue1 += 897DrawSpriteScreenXY(14, TempValue1, 11)9899// And draw its corresponding milliseconds100TempValue1 += 16101DrawNumbers(0, TempValue1, 11, Stage.MilliSeconds, 2, 8, 1)102103// And the add the remaining X space left to temp1, in order to make other HUD elements appear in their right positions104TempValue1 += 32105106end if107108// Draw the "Rings" Graphic109DrawSpriteScreenXY(12, TempValue1, 16)110111// Draw the first digit of the Rings counter112TempValue0 = Object.Rings113TempValue0 /= 100114TempValue1 += 32115DrawSpriteScreenXY(TempValue0, TempValue1, 11)116117// Then draw the second digit of the Rings counter118TempValue0 = Object.Rings119TempValue0 %= 100120TempValue0 /= 10121TempValue1 += 8122DrawSpriteScreenXY(TempValue0, TempValue1, 11)123124// And finally, draw the last, third digit of the Rings counter125TempValue0 = Object.Rings126TempValue0 %= 10127TempValue1 += 8128DrawSpriteScreenXY(TempValue0, TempValue1, 11)129130end sub131132133sub ObjectStartup134135LoadSpriteSheet("Special/Objects.gif")136137// Place the HUD object into reserved object slot 4 and initialise its values138Object[4].Type = TypeName[HUD]139140// The object should always be run, regardless if it's within camera bounds or not141Object[4].Priority = PRIORITY_ACTIVE142143// Make the HUD draw ontop of all other sprites, too144Object[4].DrawOrder = 6145146// Reset the last cleared UFO type147// (Needs to be set to -1 and not just default 0 because the Rings UFO uses type 0)148Object[4].LastUFOType = -1149150// 0-9 - Numbers 0-9151SpriteFrame(0, 0, 8, 13, 206, 84)152SpriteFrame(0, 0, 8, 13, 215, 84)153SpriteFrame(0, 0, 8, 13, 224, 84)154SpriteFrame(0, 0, 8, 13, 233, 84)155SpriteFrame(0, 0, 8, 13, 242, 84)156SpriteFrame(0, 0, 8, 13, 206, 98)157SpriteFrame(0, 0, 8, 13, 215, 98)158SpriteFrame(0, 0, 8, 13, 224, 98)159SpriteFrame(0, 0, 8, 13, 233, 98)160SpriteFrame(0, 0, 8, 13, 242, 98)161162// 10 - UFO Counter Graphic163SpriteFrame(0, 0, 24, 16, 206, 58)164165// 11 - Time Graphic166SpriteFrame(0, 0, 24, 8, 231, 58)167168// 12 - Rings Graphic169SpriteFrame(0, 0, 31, 8, 206, 75)170171// 13 - Single Tick Graphic172SpriteFrame(0, 0, 8, 13, 224, 112)173174// 14 - Double Tick Graphic175SpriteFrame(0, 0, 8, 13, 233, 112)176177end sub178179180// ========================181// Editor Subs182// ========================183184sub RSDKDraw185DrawSprite(0)186end sub187188189sub RSDKLoad190LoadSpriteSheet("Special/Objects.gif")191SpriteFrame(0, 0, 24, 16, 206, 58)192193SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")194end sub195196197