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

Type Bullet Extends TEntity
	Field speed:Float
	Field x
	Field y
	Field img:TImage
	Field ang:Float
	Field damage
	Field typ
	Field scalex:Float, scaley:Float
	
	Function CreateBullet:Bullet(img:TImage, x, y, speed:Float, damage:Float = 0, typ = 0, ang = 0, scalex:Float = 0.5, scaley:Float = 0.5)
        Local bull:Bullet = New Bullet
		bull.img = img
		bull.x = x
		bull.y = y
		bull.speed = speed
		bull.typ = typ
		bull.damage = damage
		bull.ang = ang
		bull.scalex = scalex
		bull.scaley = scaley
		bull.AddLast(SEntities)
	EndFunction
	
	
	Method Update()
		Print "LOLOLO"+scalex
		If (typ = 1) Then
			y = y - speed
		Else
			y = y + (speed * Cos(ang))
			Print (speed * Cos(ang))
        	x = x - (speed * Sin(ang))
		EndIf
		
		If (typ = 0) Then
			char:Player = PlayerLink
				If (ImagesCollide2(char.img, char.x, char.y, 0, 0, 1, 1, img, x, y, 0, ang + 180, 1, 1)) Then
					  char.armor = char.armor - damage
					  Self.remove()
				EndIf
		Else
			For enemy:TEnemy = EachIn SEnemys
				 If (ImagesCollide2(enemy.img, enemy.x, enemy.y, 0, 0, 1, 1, img, x, y, 0, ang, 1, 1)) Then
				 	enemy.health = enemy.health - damage
					Self.remove()
				 EndIf
			Next
		EndIf
		
		  If (y > height Or y < 0) Then
		  	 Self.remove()
		  End If
		If (typ = 0) Then
		SetRotation(ang + 180)
		Else
		SetRotation(ang)
		EndIf
			SetScale(scalex:Float, scaley:Float)
					DrawImage(img, x, y)
			SetScale(1, 1)
		SetRotation(0)
	End Method
	
End Type








Type Grenade Extends TEntity
	Field speed:Float
	Field x
	Field y
	Field img:TImage
	Field ang:Float
	Field damage
	Field typ
	Field scale:Float
	
	Function CreateGrenade:Grenade(img:TImage, x, y, speed:Float, damage:Float = 0, typ = 0, ang = 0, scale:Float = 0.5)
        Local gren:Grenade = New Grenade
		gren.img = img
		gren.x = x
		gren.y = y
		gren.speed = speed
		gren.typ = typ
		gren.damage = damage
		gren.ang = ang
		gren.AddLast(SEntities)
		gren.scale = scale
	EndFunction
	
	
	Method Update()
		speed = speed - 0.1
		If (speed < 0) Then
			speed = 0
			PlayerLink.armor = DamageExplosion(x, y, PlayerLink.x, PlayerLink.y, 300, PlayerLink.armor, damage)
			Self.remove()
		EndIf
		If (typ = 1) Then
			y = y - speed
		Else
			y = y + (speed * Cos(ang))
			Print (speed * Cos(ang))
        	x = x - (speed * Sin(ang))
		EndIf
		
		
		  SetColor(255, 0, 0)
		  	DrawText speed, x + img.width * 0.5, y - 10
		  SetColor(255, 255, 255)
		  If (y > height) Then
		  	 Self.remove()
		  End If
			SetScale(scale, scale)
				DrawImage(img, x, y)
			SetScale(1, 1)
	End Method
	
End Type


