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

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

private alias object.value1 : object.originPos.x
private alias object.value2 : object.originPos.y
private alias object.value3 : object.fallAngle
private alias object.value4 : object.angleVel


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

event ObjectUpdate
	object.fallAngle += object.angleVel

	temp0 = oscillation
	temp0 &= 0x1F
	if temp0 == 0
		Rand(temp0, 2)
		if temp0 == 1
			FlipSign(object.angleVel)
		end if
	end if

	object.originPos.x += object.xvel
	object.originPos.y += object.yvel
	temp0 = object.originPos.y
	temp0 &= 0x300
	temp0 += 0x400
	object.yvel += temp0

	Cos(object.xpos, object.fallAngle)
	object.xpos <<= 2
	object.xpos += object.originPos.x

	Sin(object.ypos, object.fallAngle)
	object.ypos <<= 2
	object.ypos += object.originPos.y

	object.animationTimer--
	if object.animationTimer < 0
		object.animationTimer = 11
		object.frame ^= 2
	end if

	if object.outOfBounds == true
		object.type = TypeName[Blank Object]
	end if
end event


event ObjectDraw
	DrawSprite(object.frame)
end event


event ObjectStartup
	LoadSpriteSheet("ARZ/Objects.gif")
	SpriteFrame(-4, -3, 8, 7, 155, 207)
	SpriteFrame(-7, -4, 14, 8, 164, 207)
	SpriteFrame(-8, -3, 10, 6, 181, 207)
	SpriteFrame(-8, -3, 14, 6, 155, 216)
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("ARZ/Objects.gif")
	SpriteFrame(-4, -3, 8, 7, 155, 207)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
