// ----------------------------------
// RSDK Project: Sonic 1
// Script Description: HUD Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

// ========================
// Aliases
// ========================

private alias object.value4 : object.flashTimer

// Player aliases
private alias object.value0 : player.rings


// ========================
// Events
// ========================

event ObjectDraw
	// But we don't even draw rings in the Special Stage...
	if player[0].rings == 0
		object.flashTimer++
		if object.flashTimer == 16
			object.flashTimer = 0
		end if
	else
		if stage.minutes == 9
			object.flashTimer++
			if object.flashTimer == 16
				object.flashTimer = 0
			end if
		end if
	end if

#platform: USE_STANDALONE
	DrawSpriteScreenXY(10, 17, 9)

	if stage.minutes == 9
		if object.flashTimer > 7
			DrawSpriteScreenXY(11, 17, 9)
		end if
	end if

	DrawSpriteScreenXY(13, 67, 9)
	DrawNumbers(0, 104, 9, stage.milliSeconds, 2, 8, 1)
	DrawNumbers(0, 80, 9, stage.seconds, 2, 8, 1)
	DrawNumbers(0, 56, 9, stage.minutes, 1, 8, 1)
#endplatform

#platform: USE_ORIGINS
	// This HUD isn't used in Origins, but they changed the positioning anyway
	DrawSpriteScreenXY(10, 17, 13)
	
	if stage.minutes == 9
		if object.flashTimer > 7
			DrawSpriteScreenXY(11, 17, 13)
		end if
	end if
	
	DrawSpriteScreenXY(13, 67, 13)
	DrawNumbers(0, 104, 13, stage.milliSeconds, 2, 8, 1)
	DrawNumbers(0, 80, 13, stage.seconds, 2, 8, 1)
	DrawNumbers(0, 56, 13, stage.minutes, 1, 8, 1)
#endplatform
end event


event ObjectStartup
	LoadSpriteSheet("Global/Display.gif")

	// HUD frames
	SpriteFrame(0, 0, 8, 11, 1, 50)
	SpriteFrame(0, 0, 8, 11, 10, 50)
	SpriteFrame(0, 0, 8, 11, 19, 50)
	SpriteFrame(0, 0, 8, 11, 28, 50)
	SpriteFrame(0, 0, 8, 11, 1, 62)
	SpriteFrame(0, 0, 8, 11, 10, 62)
	SpriteFrame(0, 0, 8, 11, 19, 62)
	SpriteFrame(0, 0, 8, 11, 28, 62)
	SpriteFrame(0, 0, 8, 11, 1, 74)
	SpriteFrame(0, 0, 8, 11, 10, 74)
	SpriteFrame(0, 0, 31, 11, 1, 17)
	SpriteFrame(0, 0, 31, 11, 1, 119)
	SpriteFrame(0, 0, 39, 11, 1, 131)
	SpriteFrame(0, 0, 29, 4, 1, 45)
	SpriteFrame(0, 0, 3, 11, 37, 50)
end event


// ========================
// Editor Events
// ========================

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
