// ----------------------------------
// RSDK Project: Sonic 2
// Script Description: Lose Ring 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.gravityStrength



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

event ObjectUpdate
	object.yvel += object.gravityStrength

	object.xpos += object.xvel
	object.ypos += object.yvel

	if object.scale < 0x200
		object.scale += 0x10
	end if

	object.animationTimer += object.animationSpeed
	if object.animationTimer >= 0x100
		object.animationTimer -= 0x100
		object.frame++
		if object.frame == 8
			object.frame = 0
		end if
	end if

	if object.timer < 90
		object.timer++
	else
		object.type = TypeName[Blank Object]
	end if
end event


event ObjectDraw
	temp0 = object.xpos
	temp0 >>= 16
	temp0 += screen.xcenter

	temp1 = object.ypos
	temp1 >>= 16
	
	DrawSpriteScreenFX(object.frame, FX_SCALE, temp0, temp1)
end event


event ObjectStartup
	LoadSpriteSheet("Special/Objects.gif")
	SpriteFrame(-16, -16, 32, 32, 34, 1) 	// Ring Frame 1 - #0
	SpriteFrame(-16, -16, 32, 32, 67, 1) 	// Ring Frame 2 - #1
	SpriteFrame(-16, -16, 32, 32, 100, 1)	// Ring Frame 3 - #2
	SpriteFrame(-16, -16, 32, 32, 133, 1)	// Ring Frame 4 - #3
	SpriteFrame(-16, -16, 32, 32, 166, 1)	// Ring Frame 5 - #4
	SpriteFrame(-16, -16, 32, 32, 199, 1)	// Ring Frame 6 - #5
	SpriteFrame(-16, -16, 32, 32, 1, 34) 	// Ring Frame 7 - #6
	SpriteFrame(-16, -16, 32, 32, 34, 34)	// Ring Frame 8 - #7
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("Special/Objects.gif")
	SpriteFrame(-8, -8, 16, 16, 233, 0)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
