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

//-------Aliases-------//
private alias 43 : TYPE_BIRD


// Static Values

// Tables

event ObjectMain
	switch object.state
	case 0
		Rand(object.xpos, 112)
		object.xpos += -160
		object.xpos <<= 16
		Rand(object.ypos, 224)
		object.ypos -= 112
		object.ypos += screen.cameraY
		object.ypos <<= 16
		//if stage.playerListPos == 1
		//	object.frame = 4
		//end if
		//if PlayerObject_SuperState != 0
		//	object.frame = 2
		//end if
		if object.ypos < object[0].ypos
			object.yvel = 0x2000
		else
			object.yvel = -0x2000
		end if
		object.state = 1
		break
	case 1
		object.value0--
		if object.value0 < 0
			object.value0 = 244
			if object.ypos < object[0].ypos
				object.ypos -= 0x68000
			else
				object.ypos += 0x68000
			end if
			object.state = 2
		end if
		break
	case 2
		object.xpos += 0x10000
		object.ypos += object.yvel
		object.value0--
		if object.value0 < 0
			object.value0 = 384
			object.value1 = object.ypos
			object.value2 = object.yvel
			object.yvel = 0x8000
			object.state = 3
		end if
		break
	case 3
		object.ypos += object.yvel
		if object.ypos > object.value1
			object.yvel -= 0x400
		else
			object.yvel += 0x400
		end if
		object.value0--
		if object.value0 < 0
			object.value0 = 244
			object.yvel = object.value2
			object.state = 4
		end if
		break
	case 4
		object.xpos -= 0x10000
		object.ypos += object.yvel
		object.value0--
		if object.value0 < 0
			object.type = TypeName[Blank Object]
		end if
		break
	end switch
	object.animationTimer++
	if object.animationTimer == 6
		object.animationTimer = 0
		object.frame ^= 1
	end if
end event


event ObjectDraw
	DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
end event


event ObjectStartup
	LoadSpriteSheet("Global/Items2.gif")
	SpriteFrame(-8, -7, 16, 15, 66, 239)
	SpriteFrame(-8, -8, 16, 15, 83, 239)
	SpriteFrame(-8, -8, 16, 15, 32, 239)
	SpriteFrame(-8, -7, 16, 15, 49, 239)
	SpriteFrame(-7, -8, 14, 16, 1, 239)
	SpriteFrame(-7, -8, 15, 16, 16, 239)
end event

event RSDKDraw
	DrawSprite(0)
end event

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