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

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

private alias object.value0 : object.timer
private alias object.value1 : object.logoFrame
private alias object.value2 : object.numberFrame

// States
private alias 0 : CREDITSLOGO_SETUP
private alias 1 : CREDITSLOGO_SHINEDELAY
private alias 2 : CREDITSLOGO_LOGOSHINE
private alias 3 : CREDITSLOGO_NUMBERSHINE
private alias 4 : CREDITSLOGO_SHOWLOGO

// ========================
// Tables
// ========================

private table CreditsLogo_logoFrameTable
	0, 2, 3, 4, 3, 2, 0
end table

private table CreditsLogo_numberFrameTable
	0, 5, 6, 7, 8, 7, 6, 5, 0
end table


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

event ObjectUpdate
	switch object.state
	case CREDITSLOGO_SETUP
		GetTableValue(object.logoFrame, 0, CreditsLogo_logoFrameTable)
		GetTableValue(object.numberFrame, 0, CreditsLogo_numberFrameTable)
		object.state++
		break

	case CREDITSLOGO_SHINEDELAY
		object.timer++
		if object.timer == 90
			object.timer = 0
			object.frame = 0
			object.state++
		end if
		break

	case CREDITSLOGO_LOGOSHINE
		object.timer++
		if object.timer == 2
			object.timer = 0
			object.frame++
			GetTableValue(object.logoFrame, object.frame, CreditsLogo_logoFrameTable)
			if object.frame == 6
				object.frame = 0
				object.state++
			end if
		end if
		break

	case CREDITSLOGO_NUMBERSHINE
		object.timer++
		if object.timer == 2
			object.timer = 0
			object.frame++
			GetTableValue(object.numberFrame, object.frame, CreditsLogo_numberFrameTable)
			if object.frame == 9
				object.frame = 0
				object.state++
			end if
		end if
		break

	case CREDITSLOGO_SHOWLOGO
		break
		
	end switch
end event


event ObjectDraw
	DrawSprite(1)					// SONIC 2
	DrawSprite(object.logoFrame)	// SONIC Shine
	DrawSprite(object.numberFrame)	// 2 Shine
end event


event ObjectStartup
	LoadSpriteSheet("Ending/Credits.gif")
	SpriteFrame(0, 0, 0, 0, 141, 94)		// Blank 					- #0
	SpriteFrame(-60, -20, 120, 40, 135, 53)	// SONIC 2 					- #1
	SpriteFrame(-63, -22, 81, 38, 141, 94)	// SONIC Shine - Frame 1 	- #2
	SpriteFrame(-63, -22, 81, 38, 141, 133)	// SONIC Shine - Frame 2 	- #3
	SpriteFrame(-63, -22, 81, 38, 141, 172)	// SONIC Shine - Frame 3 	- #4
	SpriteFrame(28, -20, 32, 39, 223, 94)	// "2" Shine - Frame 1 		- #5
	SpriteFrame(28, -20, 32, 39, 223, 134)	// "2" Shine - Frame 2 		- #6
	SpriteFrame(28, -20, 32, 39, 223, 174)	// "2" Shine - Frame 3 		- #7
	SpriteFrame(28, -20, 32, 39, 223, 214)	// "2" Shine - Frame 4 		- #8
end event


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

event RSDKDraw
	DrawSprite(1)					// SONIC 2
end event


event RSDKLoad
	LoadSpriteSheet("Ending/Credits.gif")
	SpriteFrame(-60, -20, 120, 40, 135, 53)	// "SONIC 2"
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
