'This BMX file was edited with BLIde ( http://www.blide.org )


Type TEnemy Extends TEntity
	Field x, y
	Field img:TImage
	Field damage
	Field score
	Field health:Float, maxhealth:Float
	Field speed
	Field scalex:Float, scaley:Float
	
End Type


Type TAsteroid Extends TEnemy
	Field ang:Float
	Field angspeed:Float
	
	Function CreateAsteroid:TAsteroid(img:TImage, x, y, damage, speed, health:Float, scalex:Float = 1, scaley:Float = 1, ang:Float = 0, angs:Float = 1)
		Local asteroid:TAsteroid = New TAsteroid
		asteroid.img = img
		asteroid.x = x
		asteroid.y = y
		asteroid.damage = damage
		asteroid.speed = speed
		asteroid.scalex = scalex
		asteroid.scaley = scaley
		asteroid.ang = ang
		asteroid.angspeed = angs
		asteroid.health = health
		asteroid.maxhealth = health
		asteroid.AddLast(SEnemys)
	End Function
	
	
	Method Update()
		y = y + speed
		If (y > height) Then
			Self.remove()
		End If
		 char:Player = PlayerLink
			If(ImagesCollide(img, x, y, 0, char.img, char.x, char.y, 0)) Then
			   Self.remove()
			   char.armor = char.armor - damage
			   TExplosion.CreateExplosion(x, y, 12, RedExplosionImg, 2)
			EndIf
		
			'Die 
		     If health < 0 Then
  				Self.remove()
				TExplosion.CreateExplosion(x, y, 12, RedExplosionImg, 0)
				LocScore = LocScore + maxhealth * 2
				ScoreEffect.CreateEffect(x + img.width * 0.5, y - img.height * 0.5, maxhealth * 2, 60, BoxFont, 255, 170, 0)
				Local rn = Rand(1, 10)
				Select rn
					Case 1
					TBonus.CreateBonus(x, y, EnergyBonusImg, 0, 80)
					Case 2
					TBonus.CreateBonus(x, y, ArmorBonusImg, 40, 0)
				End Select
			  End If
			
			
		ang = ang + angspeed
		SetRotation(ang)
			SetScale(scalex:Float, scaley:Float)
				DrawImage(img, x, y)
			SetScale(1, 1)
		SetRotation(0)
		
			If (health < maxhealth) Then
		SetColor(255, 0, 0)
			DrawRect(x, y - 5, img.width * (health / maxhealth), 5)
		SetColor(255, 255, 255)
			EndIf
	End Method
	
End Type



Type TFighterV Extends TEnemy
	Field ang:Float
	Field weap:Weapon
	Field reload:Float, MaxReload:Float
	
	
	Function CreateFighter:TFighterV(img:TImage, x, y, weapony:Weapon, speed, health:Float, scalex:Float = 1, scaley:Float = 1, ang:Float = 0)
		Local Fighter:TFighterV = New TFighterV
		Fighter.img = img
		Fighter.x = x
		Fighter.y = y
		Fighter.weap = weapony
		Fighter.health = health
		Fighter.maxhealth = health
		Fighter.MaxReload = weapony.ReloadTime * 4
		Fighter.reload = 0
		Fighter.speed = speed
		Fighter.scalex = scalex
		Fighter.scaley = scaley
		Fighter.ang = ang
		Fighter.AddLast(SEnemys)
	End Function
	
	
	Method Update()
				'Shooting
		 	reload = reload + 0.1                
			If (reload > MaxReload) Then
				reload = 0
				Bullet.CreateBullet(weap.img, x + (img.width * 0.3) , y + img.height, weap.speed, weap.damage, 0, 0)
				Bullet.CreateBullet(weap.img, x + (img.width * 0.8) , y + img.height, weap.speed, weap.damage, 0, 0)
			EndIf
									   
		
			  'Die 
		     If health < 0 Then
  				Self.remove()
				TExplosion.CreateExplosion(x, y, 12, RedExplosionImg, 2)
				LocScore = LocScore + maxhealth * 2
				ScoreEffect.CreateEffect(x + img.width * 0.5, y - img.height * 0.5, maxhealth * 2, 60, BoxFont, 255, 170, 0)
				Local rn = Rand(1, 10)
				Select rn
					Case 1
					TBonus.CreateBonus(x + img.width, y + img.height, EnergyBonusImg, 0, 80)
					Case 2
					TBonus.CreateBonus(x + img.width, y + img.height, ArmorBonusImg, 40, 0)
					Case 3
					TBonus.CreateBonus(x + img.width, y + img.height, ArmorBonusImg, 40, 0)
					Case 4
					TBonus.CreateBonus(x + img.width, y + img.height, WeaponyUpBonusImg, 0, 0, 1)
					Case 5
					TBonus.CreateBonus(x + img.width, y + img.height, ArmoryUpBonusImg, 0, 0, 0, 1)
					Case 6
					TBonus.CreateBonus(x + img.width, y + img.height, EnergyUpBonusImg, 0, 0, 0, 0, 1)
				End Select
			  End If
		
		

	
	
	
		y = y + speed
		If (y > height) Then
			Self.remove()
		End If
		 char:Player = PlayerLink
			If(ImagesCollide(img, x, y, 0, char.img, char.x, char.y, 0)) Then
			   Self.remove()
			   char.armor = char.armor - (30)
			   TExplosion.CreateExplosion(x, y, 12, RedExplosionImg, 2)
			EndIf
		
		SetRotation(ang)
			SetScale(scalex:Float, scaley:Float)
				DrawImage(img, x, y)
			SetScale(1, 1)
		SetRotation(0)
		
			If (health < maxhealth) Then
		SetColor(255, 0, 0)
			DrawRect(x, y - 5, img.width * (health / maxhealth), 5)
		SetColor(255, 255, 255)
			EndIf
	End Method
	
End Type


Type TUFO Extends TEnemy
	Field ang:Float
	Field weap:Weapon
	Field reload:Float, MaxReload:Float
	
	
	Function CreateUFO:TUFO(img:TImage, x, y, weapony:Weapon, speed, health:Float, scalex:Float = 1, scaley:Float = 1, ang:Float = 0)
		Local UFO:TUFO = New TUFO
		UFO.img = img
		UFO.x = x
		UFO.y = y
		UFO.weap = weapony
		UFO.health = health
		UFO.maxhealth = health
		UFO.MaxReload = weapony.ReloadTime * 8
		UFO.reload = 0
		UFO.speed = speed
		UFO.scalex = scalex
		UFO.scaley = scaley
		UFO.ang = ang
		UFO.AddLast(SEnemys)
	End Function
	
	
	Method Update()
				'Shooting
		 	reload = reload + 0.1                
			If (reload > MaxReload) Then
				reload = 0
				
				Bullet.CreateBullet(weap.img, x + (img.width * 0.3) , y + img.height, weap.speed, weap.damage, 0, Angle(x, y, PlayerLink.x, PlayerLink.y))
			EndIf
									   
		

			
		
		 'Die 
		     If health < 0 Then
  				Self.remove()
				TExplosion.CreateExplosion(x - img.width * 0.5, y - img.height * 0.5, 12, BlueExplosionImg, 2)
				LocScore = LocScore + maxhealth * 2
				ScoreEffect.CreateEffect(x, y, maxhealth * 2, 60, BoxFont, 255, 170, 0)
				Local rn = Rand(1, 10)
				Select rn
					Case 1
					TBonus.CreateBonus(x, y, EnergyBonusImg, 0, 80)
					Case 2
					TBonus.CreateBonus(x, y, ArmorBonusImg, 40, 0)
				End Select
			  End If
	
	
		ang = ang + 1
		y = y + speed
		If (y > height) Then
			Self.remove()
		End If
		 char:Player = PlayerLink
			If(ImagesCollide2(char.img, char.x, char.y, 0, 0, 1, 1, img, x, y, 0, ang, 1, 1)) Then
			   Self.remove()
			   char.armor = char.armor - (30)
			   TExplosion.CreateExplosion(x - img.width * 0.5, y - img.height * 0.5, 12, BlueExplosionImg, 2)
			EndIf
		
		SetRotation(ang)
			SetScale(scalex:Float, scaley:Float)
				DrawImage(img, x, y)
			SetScale(1, 1)
		SetRotation(0)
		
			if (health<maxhealth ) then 
		SetColor(255, 0, 0)
			DrawRect(x - img.width * 0.5, y - 5 - img.height * 0.5, img.width * (health / maxhealth), 5)
		SetColor(255, 255, 255)
			EndIf
	End Method
	
End Type


Type TRanger Extends TEnemy
	Field ang:Float
	Field weap:Weapon
	Field reload:Float, MaxReload:Float
	Field speedx
	
	
	Function CreateRanger:TRanger(img:TImage, x, y, weapony:Weapon, speed, health:Float, scalex:Float = 1, scaley:Float = 1, ang:Float = 0)
		Local Ranger:TRanger = New TRanger
		Ranger.img = img
		Ranger.x = x
		Ranger.y = y
		Ranger.weap = weapony
		Ranger.health = health
		Ranger.maxhealth = health
		Ranger.MaxReload = weapony.ReloadTime * 4
		Ranger.reload = 0
		Ranger.speed = speed
		Ranger.scalex = scalex
		Ranger.scaley = scaley
		Ranger.ang = ang
		Ranger.speedx = Rand(-3, 3)
		Ranger.AddLast(SEnemys)
		
	End Function
	
	
	Method Update()
				'Shooting
		 	reload = reload + 0.1                
			If (reload > MaxReload) Then
				reload = 0
				Bullet.CreateBullet(weap.img, x + (img.width * 0.5) , y + img.height, weap.speed, weap.damage, 0, 0)
			EndIf
			
			x = x + speedx
									   
			 'Die 
		     If health < 0 Then
  				Self.remove()
				TExplosion.CreateExplosion(x, y, 16, ExplosionImg, 1)
				LocScore = LocScore + maxhealth * 2
				ScoreEffect.CreateEffect(x + img.width * 0.5, y - img.height * 0.5, maxhealth * 2, 60, BoxFont, 255, 170, 0)
				Local rn = Rand(1, 10)
				Select rn
					Case 1
					TBonus.CreateBonus(x + img.width, y + img.height, EnergyBonusImg, 0, 80)
					Case 2
					TBonus.CreateBonus(x + img.width, y + img.height, ArmorBonusImg, 40, 0)
					Case 3
					TBonus.CreateBonus(x + img.width, y + img.height, ArmorBonusImg, 40, 0)
					Case 4
					TBonus.CreateBonus(x + img.width, y + img.height, WeaponyUpBonusImg, 0, 0, 1)
					Case 5
					TBonus.CreateBonus(x + img.width, y + img.height, ArmoryUpBonusImg, 0, 0, 0, 1)
					Case 6
					TBonus.CreateBonus(x + img.width, y + img.height, EnergyUpBonusImg, 0, 0, 0, 0, 1)
					Case 7
					TBonus.CreateBonus(x + img.width, y + img.height, EnergyBonusImg, 0, 80)
				End Select
			  End If

		
		

	
	
	
		y = y + speed
		If (y > height or x>width) Then
			Self.remove()
		End If
		 char:Player = PlayerLink
			If(ImagesCollide(img, x, y, 0, char.img, char.x, char.y, 0)) Then
			   Self.remove()
			   char.armor = char.armor - (30)
			   TExplosion.CreateExplosion(x, y, 16, ExplosionImg, 1)
			   
			EndIf
		
		SetRotation(ang)
			SetScale(scalex:Float, scaley:Float)
				DrawImage(img, x, y)
			SetScale(1, 1)
		SetRotation(0)
		
			If (health < maxhealth) Then
		SetColor(255, 0, 0)
			DrawRect(x, y - 5, img.width * (health / maxhealth), 5)
		SetColor(255, 255, 255)
			EndIf
	End Method
	
End Type


 Type TBombCruiser Extends TEnemy
	Field ang:Float
	Field weap:Weapon
	Field reload:Float, MaxReload:Float
	
	
	Function CreateBombCruiser:TBombCruiser(img:TImage, x, y, weapony:Weapon, speed, health:Float, scalex:Float = 1, scaley:Float = 1, ang:Float = 0)
		Local BombCruiser:TBombCruiser = New TBombCruiser
		BombCruiser.img = img
		BombCruiser.x = x
		BombCruiser.y = y
		BombCruiser.weap = weapony
		BombCruiser.health = health
		BombCruiser.maxhealth = health
		BombCruiser.MaxReload = weapony.ReloadTime * 4
		BombCruiser.reload = 0
		BombCruiser.speed = speed
		BombCruiser.scalex = scalex
		BombCruiser.scaley = scaley
		BombCruiser.ang = ang
		BombCruiser.AddLast(SEnemys)
	End Function
	
	
	Method Update()
				'Shooting
		 	reload = reload + 0.1                
			If (reload > MaxReload) Then
				reload = 0
				Grenade.CreateGrenade(weap.img, x + (img.width * 0.3) , y + img.height, weap.speed + Rand(-3, 3), weap.damage, 0, Rand(-30, 30))
			EndIf
									   
		
		   'Die 
		     If health < 0 Then
  				Self.remove()
				TExplosion.CreateExplosion(x, y, 20, SkybusterExplosion, 2)
				LocScore = LocScore + maxhealth * 2
				ScoreEffect.CreateEffect(x + img.width * 0.5, y - img.height * 0.5, maxhealth * 2, 60, BoxFont, 255, 170, 0)
				Local rn = Rand(1, 10)
				Select rn
					Case 1
					TBonus.CreateBonus(x + img.width, y + img.height, EnergyBonusImg, 0, 80)
					Case 2
					TBonus.CreateBonus(x + img.width, y + img.height, EnergyBonusImg, 0, 80)
					Case 3
					TBonus.CreateBonus(x + img.width, y + img.height, ArmorBonusImg, 40, 0)
					Case 4
					TBonus.CreateBonus(x + img.width, y + img.height, WeaponyUpBonusImg, 0, 0, 1)
					Case 5
					TBonus.CreateBonus(x + img.width, y + img.height, ArmoryUpBonusImg, 0, 0, 0, 1)
					Case 6
					TBonus.CreateBonus(x + img.width, y + img.height, EnergyUpBonusImg, 0, 0, 0, 0, 1)
				End Select
			  End If
		
		

	
	
	
		y = y + speed
		If (y > height) Then
			Self.remove()
		End If
		 char:Player = PlayerLink
			If(ImagesCollide(img, x, y, 0, char.img, char.x, char.y, 0)) Then
			   Self.remove()
			   char.armor = char.armor - (30)
			   TExplosion.CreateExplosion(x, y, 20, SkybusterExplosion, 2)
			EndIf
		
		SetRotation(ang)
			SetScale(scalex:Float, scaley:Float)
				DrawImage(img, x, y)
			SetScale(1, 1)
		SetRotation(0)
		
			If (health < maxhealth) Then
		SetColor(255, 0, 0)
			DrawRect(x, y - 5, img.width * (health / maxhealth), 5)
		SetColor(255, 255, 255)
			EndIf
	End Method
	
End Type


Type THAWK Extends TEnemy
	Field ang:Float
	Field weap:Weapon
	Field reload:Float, MaxReload:Float
	
	
	Function CreateHAWK:THAWK(img:TImage, x, y, weapony:Weapon, speed, health:Float, scalex:Float = 1, scaley:Float = 1, ang:Float = 0)
		Local HAWK:THAWK = New THAWK
		HAWK.img = img
		HAWK.x = x
		HAWK.y = y
		HAWK.weap = weapony
		HAWK.health = health
		HAWK.maxhealth = health
		HAWK.MaxReload = weapony.ReloadTime * 4
		HAWK.reload = 0
		HAWK.speed = speed
		HAWK.scalex = scalex
		HAWK.scaley = scaley
		HAWK.ang = ang
		HAWK.AddLast(SEnemys)
	End Function
	
	
	Method Update()
				'Shooting
		 	reload = reload + 0.1                
			If (reload > MaxReload) Then
				reload = 0
				
				Bullet.CreateBullet(weap.img, x, y, weap.speed, weap.damage, 0, Angle(x, y, PlayerLink.x, PlayerLink.y))
			EndIf
									   
		

			
		
		 'Die 
		     If health < 0 Then
  				Self.remove()
				TExplosion.CreateExplosion(x - img.width * 0.5, y - img.height * 0.5, 12, BlueExplosionImg, 2)
				LocScore = LocScore + maxhealth * 2
				ScoreEffect.CreateEffect(x + img.width * 0.5, y - img.height * 0.5, maxhealth * 2, 60, BoxFont, 255, 170, 0)
				Local rn = Rand(1, 10)
				Select rn
					Case 1
					TBonus.CreateBonus(x, y, EnergyBonusImg, 0, 80)
					Case 2
					TBonus.CreateBonus(x, y, EnergyBonusImg, 00, 80)
					Case 3
					TBonus.CreateBonus(x, y, ArmorBonusImg, 40, 0)
					Case 4
					TBonus.CreateBonus(x, y, WeaponyUpBonusImg, 0, 0, 1)
					Case 5
					TBonus.CreateBonus(x, y, ArmoryUpBonusImg, 0, 0, 0, 1)
					Case 6                   
					TBonus.CreateBonus(x, y, EnergyUpBonusImg, 0, 0, 0, 0, 1)
				End Select
			  End If
	
	
		ang = Angle(x, y, PlayerLink.x, PlayerLink.y)
		
		If(y < height * 0.2) Then
			y = y + speed
		EndIf 
		
		
		If (y > height) Then
			Self.remove()
		End If
		 char:Player = PlayerLink
			If(ImagesCollide2(char.img, char.x, char.y, 0, 0, 1, 1, img, x, y, 0, ang, 1, 1)) Then
			   Self.remove()
			   char.armor = char.armor - (30)
			   
			   TExplosion.CreateExplosion(x - img.width * 0.5, y - img.height * 0.5, 12, BlueExplosionImg, 2)
			EndIf
		
		SetRotation(ang)
			SetScale(scalex:Float, scaley:Float)
				DrawImage(img, x, y)
			SetScale(1, 1)
		SetRotation(0)
		
			if (health<maxhealth ) then 
		SetColor(255, 0, 0)
			DrawRect(x - img.width * 0.5, y - 5 - img.height * 0.5, img.width * (health / maxhealth), 5)
		SetColor(255, 255, 255)
			EndIf
	End Method
	
End Type










Function Angle:Double(x0:Double, y0:Double, x1:Double, y1:Double)
        Return ATan2(y1 - y0, x1 - x0) + 270
End Function