Constructor CLevel::CLevel()
	m_iBackImgID = agk::LoadImage("space/space.jpg")
	m_iObstacleImgID = agk::LoadImage("space/MetalBlock1.png")
	
	m_iBackSprID = agk::CreateSprite(m_iBackImgID)
	agk::SetSpriteSize(m_iBackSprID,agk::GetScreenBoundsRight() + agk::Abs(agk::GetScreenBoundsLeft()), agk::GetScreenBoundsBottom() + agk::Abs(agk::GetScreenBoundsTop()))
	agk::SetSpritePosition(m_iBackSprID, (float)agk::GetScreenBoundsLeft(), (float)agk::GetScreenBoundsTop())
	agk::FixSpriteToScreen(m_iBackSprID,1)
	
	m_iStartfieldPfxID = agk::CreateParticles(550.0, 0.0)
	
	agk::SetParticlesImage(m_iStartfieldPfxID, m_iStartfieldImgID)
	agk::SetParticlesStartZone(m_iStartfieldPfxID, 0, 10, 0, 400)
	agk::SetParticlesDirection(m_iStartfieldPfxID, -50.0, 0.0)
	agk::SetParticlesLife(m_iStartfieldPfxID, 15)
	agk::SetParticlesSize(m_iStartfieldPfxID, 4)
	agk::SetParticlesAngle(m_iStartfieldPfxID, 0)
	agk::SetParticlesFrequency(m_iStartfieldPfxID, 60)
	agk::SetParticlesVelocityRange(m_iStartfieldPfxID, 0.5, 4.0)
	agk::FixParticlesToScreen(m_iStartfieldPfxID, 1)
	
	m_iObstacleImgID = agk::LoadImage("space/MetalBlock1.png")
	
	this->CreateStrip(m_iObstacleImgID, 32.0f, 0.0f, 0)
	
	this->CreateStrip(m_iObstacleImgID, 25.0f, 0.0f, 1)
	
	this->CreateStrip(m_iObstacleImgID, (float)agk::GetScreenBoundsLeft(),(float)agk::GetScreenBoundsTop(), 2)
End Constructor

Destructor CLevel::~CLevel()

End Destructor

Function CLevel::CheckCollisionWithLevel(iSprite As integer) As integer
	For integer i = 0 to m_iSceneryCount-1
		If agk::GetSpriteExists(m_iScenery[i]) = 1 Then
			If agk::GetSpriteCollision(iSprite, m_iScenery[i]) = 1 Then
				Function = 1
			EndIf
		EndIf
	Next
	Function = 0
End Function

Sub CLevel::CreateStrip(iImage As integer, fX As float, fY As float, iMode As integer)
	For integer i = 0 to 250
		Raw As integer built = 0
		Raw As integer iSprite = -1
		Raw As integer iSpriteB = -1
		
		If iMode = 0 Then
			If agk::Random(1,2) = 1 Then
				iSprite = agk::CreateSprite(iImage)
				agk::SetSpritePosition(iSprite,fX, float(368 - agk::Random(64, 64 + 32)))
				built = 1
			EndIf
			
			If fX > 300 And agk::Random(1,5) = 3 Then
				iSpriteB = agk::CreateSprite(iImage)
				agk::SetSpritePosition(iSpriteB, fX, float(agk::Random(120,200)))
				agk::SetSpriteColor(iSpriteB, 255, 255, 255, 200)
				agk::SetSpriteAngle(iSpriteB, float(agk::Random(0,360)))
				built = 1
			EndIf
		EndIf
		
		If iMode = 1 Then
			If agk::Random(1,3) = 1 Then
				iSprite = agk::CreateSprite(iImage)
				agk::SetSpritePosition(iSprite, fX, float(agk::Random(32,64)))
				built = 1
			EndIf
		EndIf
		
		If iMode = 2 Then
			iSprite = agk::CreateSprite(iImage)
			agk::SetSpritePosition(iSprite, fX, 0.0)
			
			iSpriteB = agk::CreateSprite(iImage)
			agk::SetSpritePosition(iSpriteB, fX, 400 - 64)
			built = 1
		EndIf
		
		If built = 1 Then
			If iSprite <> -1 Then
				m_iScenery[m_iSceneryCount] = iSprite
				Incr m_iSceneryCount
			EndIf
			
			If iSpriteB <> -1 Then
				m_iScenery[m_iSceneryCount] = iSpriteB
				Incr m_iSceneryCount
			EndIf
		EndIf
		
		fX = fX + 64
	Next
End Sub
