Beginners Community Project - Space Invaders

Blitz3D Forums/Blitz3D Beginners Area/Beginners Community Project - Space Invaders

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Function Set_Up_Control()
control.Control_Type = New Control_Type
control\max_bombs = 5
control\bomb_speed = 3
control\crit_drop_Speed = 17
control\drop_bomb_chance = 5
control\player_StartSpeed = 4
control\player_speed = control\player_StartSpeed
control\bullet_speed = 20
control\max_rows = 6
control\max_cols = 10
control\xres = 640 ; Try this pair at different resolution: 640,480 or 1024,768 or 1280,1024
control\yres = 480; 
control\depth = 32;
control\level = 1
control\Beast_Speed = 2
control\Beast_Speed_Increment = .05
;+++ speed and direction of ufo
control\UFO_Speed = 2
control\UFO_dir = 0




End Function

Function Do_Points()
For point = Each points_type
	DrawImage points_Ims(point\id),point\x,point\y
	point\id = point\id + 1
	If point\id > 15 Then Delete point
Next
End Function

Function Make_Ship()
ship = CreateImage(64,16)
SetBuffer ImageBuffer(ship)
Rect 0,8,64,8,True
Rect 16,4,32,4,True
Rect 24,0,16,4,True
SaveImage ship,"images\ship01.bmp"
End Function

Function DoKeys()

 
If KeyDown(57) Then
For bullet.Bullet_Type = Each Bullet_Type

	If bullet\fired = False Then
		bullet\x = player\x : bullet\y = player\y
		bullet\fired = True
		
		
			
			
			
			If ChannelPlaying (fifthsound) = 0  Then 
				fifthsound=PlaySound ( shootSound )
				ChannelPitch fifthsound,5600
				
			ElseIf ChannelPlaying (fifthsound) = 1 Then 
				StopChannel fifthsound
				FreeSound fifthsound  

 			EndIf 
		

	EndIf
Next	
EndIf

If player\moved = False Then
	If KeyDown(205) Or MouseDown (2) Then
		If player\x < 608 Then player\x = player\x + control\player_speed : player\moved = True
	EndIf
		
	If KeyDown(203) Or MouseDown (1) Then
		If player\x > 16 Then player\x = player\x - control\player_speed : player\moved = True
	EndIf
EndIf

If KeyDown(1) Then EndGame = True

End Function

Function DoExplosion()
For explosion = Each explosion_type
	DrawImage debri(explosion\id), explosion\x, explosion\y
	Select explosion\status
		Case 0
			explosion\dirx = Int(Rand(.5))-.5
			explosion\diry = Int(Rand(.5))-.5
			explosion\status = 1
			explosion\count = 1
			
		Case 1
			explosion\x = explosion\x + explosion\dirx
			explosion\y = explosion\y + explosion\diry
			explosion\count=explosion\count - 1 
			If explosion\count<=0 Then explosion\status = 2
		Case 2
			explosion\y=explosion\y+explosion\speed
			If explosion\y > 480 Then Delete explosion
		Default
			; There should be no other options so delete the explosion
			Delete explosion
	End Select		
Next
;+++ secondary weapon selection
	Select MouseZSpeed ()
		Case -1
			zspeed=zspeed+1
		Case 0
			zspeed=0
		Case 1
			zspeed=zpeed-1
	End Select
	 
End Function

Function Check_Bullets_And_UFO()
For bullet.Bullet_Type = Each Bullet_Type
If bullet\fired = True Then
	If ufo\status = True Then
		If ImagesCollide(ufo_Im,ufo\x,ufo\y,0,bullet_im,bullet\x,bullet\y,0) Then
			ufo\status = False
			Make_Explosion ufo\x,ufo\y,25
			player\score = player\score + 50
			If bonus\active = False Then
				bonus\active = True
				bonus\x = ufo\x : bonus\y = ufo\y
			End If
		EndIf
	EndIf
EndIf
Next 
End Function

;Function Move_And_Draw_Bullet()
	;bullet\y = bullet\y - control\bullet_Speed              " old function"
	
	;DrawImage bullet_im,bullet\x,bullet\y
;
;End Function

Function Make_Bullet()
; This creates the players bullet used throughout the whole game
	bullet.Bullet_Type = New Bullet_Type	; create bullet
	bullet\fired = False		; set that it's not been fired
	bullet\frame = 0
End Function

Function Move_And_Draw_Bullet()
For bullet.Bullet_Type = Each Bullet_Type
	bullet\y = bullet\y - control\bullet_Speed 
	           
	If bullet\y < 1 Then 
		;dest = True
	Else 
		dest = False 
	EndIf
	;If bullet\y < 0 Then 
				
			;EndIf 
 
	
	Select dest
	
		Case False   
	
		;If MilliSecs() > rtimer# Then 
	
			bullet\frame = bullet\frame + 1 
			If bullet\frame = 16 Then bullet\frame = 0 
			DrawImage rappedfire_im,bullet\x,bullet\y,bullet\frame
		
		;EndIf
		
		Case True 
		

			Delete bullet
			
			;If bullet = Null Then 
				;d = d + 1
			;EndIf 
			 
		End Select 
	
Next 
d = d + 1		
Text 100,300,"d :" + d	 
End Function


Function Check_Bullets_And_Bases()
For bullet.Bullet_Type = Each Bullet_Type

	If bullet\fired = True Then
		For i = 0 To 2
			If ImagesCollide(bases(i),192+(i*128),400,0,bullet_im,bullet\x,bullet\y,0) Then
				If player\Non_Expiring_Shot = False Then bullet\fired = False
					SetBuffer ImageBuffer(bases(i))
					
				
					xp = bullet\x - (160 + (i * 128))

					yp = bullet\y - 380
				
					draw_Blank xp,yp
					SetBuffer BackBuffer()
			EndIf
			If bullet\fired = False Then Exit
		Next

		If bullet\y < 0 Then 
			bullet\fired = False
			
		EndIf
	EndIf
Next 
End Function



Function Make_Points_Ims()
For i = 0 To 15
	Points_Ims(i) = CreateImage(32,32)
	Color 0,255-(i Shl 4), 0
	SetBuffer ImageBuffer(Points_Ims(i))
	Oval 16-i,16-i,i Shl 1 ,i Shl 1,False
	Text 16,16,"10",True,True
Next	
End Function

Function Add_Point(x,y)
	point = New points_type
	point\x = x : point\y = y
	point\id = 0
End Function

Function Move_Stars();Move stars*********************************************************

	stars(0)\y = (stars(0)\y -1) And 255
	TileBlock stars(0)\image,stars(0)\x,stars(0)\y

	stars(1)\y = (stars(1)\y-2) And 255
	TileImage stars(1)\image,stars(1)\x+4,stars(1)\y

	stars(2)\y = (stars(2)\y-4) And 255
	TileImage stars(2)\image,stars(2)\x,stars(2)\y

End Function

Function Make_Stars()

stars(0) = New stars_type
stars(0)\image = CreateImage(256,256)
stars(0)\count = Rand(256)
stars(0)\x = Rand(256)
SetBuffer ImageBuffer(stars(0)\image)
Color 64,64,255
For i = 0 To 31
	x = Rand(256)
	y = Rand(256)
	Rect x,y,1,1,True
Next

stars(1) = New stars_type
stars(1)\count = Rand(256)
stars(1)\x = Rand(256)
stars(1)\image = CreateImage(256,256)
SetBuffer ImageBuffer(stars(1)\image)
Color 128,128,128
For i = 0 To 16
	x = Rand(256)
	y = Rand(256)

	Rect x,y,1,1,True
Next

stars(2) = New stars_type
stars(2)\count = Rand(256)
stars(2)\x = Rand(256)
stars(2)\image = CreateImage(256,256)
SetBuffer ImageBuffer(stars(2)\image)
Color 255,255,255

For i = 0 To 15
	x = Rand(256)
	y = Rand(256)
	Rect x,y,1,1,True
Next

End Function

Function New_Ufo()

If ufo\status = False Then
;+++ set up a local variable to determon when ufo appears. it will also 
;deside what side of the screen it comes from (ufo_comes). If the UFO comes from the Left side of the 
;screen we use 8 becouse we want to use the 8th image from the 16 rotations image array.   
ufo_comes=Rnd(1000)
	If ufo_comes < 10 Then
		If ufo_comes < 5 Then
			control\ufo_speed=-Rnd(2,4)
			control\ufo_dir=8 ;+++ Face Left
			ufo\status = True
			ufo\x = 0
			ufo\y = 25
		EndIf 
		If ufo_comes > 5 Then
			control\ufo_speed=Rnd(2,4)
			control\ufo_dir=0 ;+++ Face Right
			ufo\status = True 
			ufo\x = 640
			ufo\y = 25
		EndIf 
 	EndIf
EndIf

End Function

Function Move_Ufo()

	ufo\x = ufo\x - control\ufo_speed
	If ufo\x < 0 Or ufo\x > 640 Then
		ufo\status = False
	EndIf
	;DrawImage ufo_im,ufo\x,ufo\y
	DrawImage rot_im_array(control\ufo_dir),ufo\x,ufo\y

End Function

;Function Make_Ufo_Old()
	;ufo_im = CreateImage(64,16)
	;Color 0,255,0
	;SetBuffer ImageBuffer(ufo_im)
	;Oval 32,8,32,8,True
;End Function

Function Draw_Blank(xp,yp)
	MaskImage blank_im,0,0,0
	DrawImage blank_im,xp,yp
End Function

Function Make_Blank()
	SetBuffer ImageBuffer(blank_im)
	MaskImage blank_im,255,0,255
	Color 255,0,255
	Rect 0,0,6,24,True
End Function

Function Make_Collision_Image();Bim=========Bim======Bim=========Bim========Bim=========Bim
bim = CreateImage(24,24)
SetBuffer ImageBuffer(bim)
ClsColor 0,0,0
Cls
Color 255,255,255
Oval 8,8,8,8,True
SetBuffer BackBuffer()

End Function

Function Make_Debri()
; This function creates the images used for the debri of the beasts ships
; It creates 15 images to choose from to use for falling debri by
; creating an image, setting the draw buffer to the image buffer, setting a random colour,
; and finally drawing a solid rectangle in that color
For i = 0 To 15
	debri(i) = CreateImage(2,2)
	SetBuffer ImageBuffer(debri(i))
	Select Rand(3)
		Case 0
			Color Rand(255),0,0
		Case 1
			Color 255,Rand(255),0
		Case 2
			Color 255,255,255
		Default
			Color 255,255,0
	End Select
	Rect 0,0,2,2,True
	
Next
End Function

Function Make_Player()
; This creates the player
player\x = 320 : player\y = 460			; position player on screen
player\score = 0
player\lives = 3
End Function

Function Make_Beasts()
; this produces a grid of beasts and puts them into their correct positions on screen
Delete Each beast_type
total_beasts = 0
beast_count = 0
For y = 0 To control\max_rows		; go through the rows
	For x = 0 To control\max_cols	; go through the columns
		beast = New beast_type		; create a new beast
		beast\x = x * 32.00			; place it at position using logical arithmetic, equivalent to x * 32
		beast\y = y * 32.0 + 64.0		; place it at position using logical arithmetic, equivalent to (y * 32)+32
		beast_count = beast_count + 1	; increase the number of beasts
	Next
Next

total_beasts = beast_count	; we need to know how many there originally were

End Function


Function Increase_Beast_Speed()
If dir < 0 Then 
	dir = dir - control\beast_speed_increment	
Else
	dir = dir + control\beast_speed_increment	
EndIf
End Function

Function Make_Explosion(x,y,sparks)
For i = 0 To sparks
	explosion = New explosion_type
	explosion\x = x + Rand(50)-25
	explosion\y = y + Rand(50)-25
	explosion\speed = Rand(10)+1
	explosion\status = 0
	explosion\id = Rand(15)
Next
End Function

Function DisplayStartScreen()
SetBuffer BackBuffer()
screentimer# = MilliSecs()
display_highscore = False

done = False : quit = False
While Not done
	WaitTimer(frameTimer);+++

	Cls
	move_stars
	If KeyDown(1) Then done = True : quit = True
	If KeyDown(57) Then done = True
	If display_highscore = False Then 
		SpaceyText 400,100,"SPACE INVADERS",True
		SpaceyText 400,164,"SPACE TO BEGIN",True
		SpaceyText 400,196,"ESC TO EXIT",True
	Else
		SpaceyText 400,100,"High Score Table",True
		For i = 0 To 9
			SpaceyText 200,116 + (i Shl 4), highscores(i)\score, False
			SpaceyText 400,116 + (i Shl 4), highscores(i)\name, False
		Next
	End If
	
	If MilliSecs()>(screentimer+5000) Then 
		screentimer = MilliSecs()
		display_highscore = Not(display_highscore)
	End If
	Flip	
Wend

Return quit
FlushKeys
End Function

Function Display_Info()
	Text control\xres - (Len(Str(player\score))*16),0,player\score
	For i = 0 To (player\lives-1)
		DrawImage ship_im, 32 + i Shl 6, 16
	Next 
End Function

Function DisplayEndScreen()
	FlushKeys
	screentimer = MilliSecs()
	While MilliSecs()<screentimer+2000
	WaitTimer(frameTimer);+++

		Cls
		Move_Stars
		SpaceyText 200,400,"GAME OVER",True
		Flip
	Wend
	FlushKeys
End Function

Function Make_SpaceyFont()
For i = 0 To 39
	SpaceyFont(i) = CreateImage(32,48)
	MidHandle SpaceyFont(i)
	SetBuffer ImageBuffer(SpaceyFont(i))
	ch$ = Mid$(char$, i+1,1)
	Select ch
		Case "@"
			Text 4,8,"DEL"
		Case "#"
			Text 4,8,"END"
		Case "~"
			Rect 0,0,32,32,False
		Default 
			Text 12,8,ch$
	End Select
Next
End Function

Function EnterHighScore()
name$ = ""
pos = 10
For i = 9 To 0 Step -1
	If player\score>highscores(i)\score Then pos = i
Next

If pos<10 Then
	done = False
	
	x = 0 : y = 0

	keypresstimer# = MilliSecs()
	keypressed = False
	
	While Not(done)
	WaitTimer(frameTimer);+++

		Cls
		Move_Stars
		yp = 0 : xp = 0
		For i = 0 To 38
			DrawImage SpaceyFont(i),160 + xp * 32, 100 + yp * 32
			xp = xp + 1 : If xp>9 Then xp = 0 : yp=yp+1
		Next	
				
		If keypressed = False Then
			If KeyDown(203) Then x = x - 1 : keypressed = True : If x < 0 Then x = 0
			If KeyDown(205) Then x = x + 1 : keypressed = True : If x > 9 Then x = 9
			If KeyDown(200) Then y = y - 1 : keypressed = True : If y < 0 Then y = 0
			If KeyDown(208) Then y = y + 1 : keypressed = True : If y > 3 Then y = 3

			If KeyDown(57) Then
				keypressed =True
				ch = (x + y*10)+1
				Select Mid(char$,ch,1)
					Case "@"
						If Len(name)>0 Then
							name = Left(name, Len(name)-1)
						End If
					Case "#"
						done = True
					Case "~"
					Default
						If Len(name)<5 Then name = name + Mid(char$,ch,1)
				End Select
			End If			

			If keypressed = True Then keypresstimer = MilliSecs()

		End If
	
		If MilliSecs()>keypresstimer + 100 Then keypressed = False
		
		If ((x) + (y*10)) > 38 Then x = x -1		
		DrawImage SpaceyFont(39), 160 + x * 32, 100 + y * 32
		
		SpaceyText 100,400,name,True
		If KeyDown(1) Then done = True
		Flip
	Wend
		
	For i = 8 To pos Step -1
		highscores(i+1)\score = highscores(i)\score
		highscores(i+1)\name = highscores(i)\name
	Next
	
	highscores(pos)\score = player\score
	highscores(pos)\name = name
End If
End Function

Function Make_Highscoretable()
For i = 9 To 0 Step -1
	highscores(i) = New highscoretable_type
	highscores(i)\score = score
	highscores(i)\name = "Bob"
	score = score + 100
Next
End Function

Function StartNewLevel()
	Delete Each bomb_type
	Make_Beasts
	Make_Bases
	
	


	control\Beast_Speed = 1 + (control\level/2)
	dir = control\beast_speed
End Function

Function Introduce_Level()
timer# = MilliSecs()
While MilliSecs()<timer + 500
	WaitTimer(frameTimer);+++

	Cls
	Move_Stars
	SpaceyText 300,200,"Level : " + control\level, True
	Flip
Wend
End Function

Function Make_Player_Image()
ship_im = CreateImage(50,50)
SetBuffer ImageBuffer(ship_im)
;ClsColor 0,0,0
;Color 255,255,255
;Rect 24,0,16,4,True
;Rect 16,4,32,4,True
;Rect 8,8,48,4,True
;Rect 0,12,64,4,True
;ship
;drawing of player ship
For i = 1 To 15
	Color 100-(i*5),100-(i*5),100-(i*5)

	Line 15-(i/10),15+i,35+(i/10),15+i ;front underchasi
Next
For i = 1 To 15
	Color 100-(i*5),100-(i*5),100-(i*5)

	Line 14+i/4,30+i,36-i/4,30+i ;rear under chassi
Next 
For i = 1 To 10
	Color 100-(i*5),100-(i*5),100-(i*5)

	Line 23-(i/2),0+i,27+(i/2),0+i ;nose
Next
For i = 1 To 15
	Color 80-(i*5),80-(i*5),80-(i*5)

	Line 17+(i/7),10+i,33-(i/7),10+i ;neck	
Next
For i = 1 To 15
	Color 80+i,80+i,80+i

	Line 23-i,17+i,27+i,17+i ;front of wing
Next
For i = 1 To 5
	Color 80-i,80-(i*2),80-i

	Line 10,32+i,40,32+i ;rear of wing
Next
For i = 1 To 5
	Color 80-(i*5),80-(i*5),80-(i*5)

	Line 20,45+i,30,45+i
Next 
For i = 1 To 3
	Color 100-(i*15),100-(i*15),100-(i*15)
	Line 6-i,15,6-i,40         ; rockets
	Line 6+i,15,6+i,40

	Line 44-i,15,44-i,40
	Line 44+i,15,44+i,40
Next
For i = 1 To 5
	Color 50,50,50
	Line 3+(i/2),15-i,9-(i/2),15-i
	Line 41+(i/2),15-i,47-(i/2),15-i
Next 
Line 3,15,9,15
Line 41,15,47,15
Color 120,120,120 ;rocket detail
Line 6,10,6,40
Line 44,10,44,40
For i = 1 To 4
Color 60-i,60-i,60-i
	Line 3,41,9,41
	Line 41,41,47,41
	Line 3-Floor(i/2),41+i,9+Floor(i/2),41+i  ;rocket flares
	Line 41-Floor(i/2),41+i,47+Floor(i/2),41+i
Next
Color 120,120,120
Line 6,41,6,45 ;left flare details
Line 3,41,1,45
Line 9,41,11,45
Line 44,41,44,45 ;Right flare details
Line 41,41,39,45
Line 47,41,49,45
 ;ship highlights and little details
Color 140,50,50
Line 23,17,27,17
For i = 1 To 5
	Color 120-(i*10),50,50   ;window with red light reflection on nose
	Line 23-i,16-i,27+i,16-i
Next

For i = 1 To 12
	Color 80+i*2,80+i*2,80+i*2 
	Line 23-i,20+i,27+i,20+i
Next

For i = 10 To 40 Step 5 ;some back detail to break up the color a little
	Color 120,120,120
	Line 0+i,32,0+i,37
Next 
;For i = 1 To 3
	;Color 100-(i*15),100-(i*15),100-(i*15)
	;Line 25-i,20,25-i,45-i
	;Line 25+i,20,25+i,45-i
;Next 
;Color 120,120,120 
ScaleImage ship_im,.75,.75
SetBuffer BackBuffer()
End Function

Function Make_Beast_Images()
For i = 0 To 15

	im(i) = CreateImage(50,50)
	SetBuffer ImageBuffer(im(i))

For l = 1 To 4
	Color 50+(l*5),100+(l*5),50+(l*5)
	Line 25+l,0+(l*2),25+l,25-(l*2)  ;center body
	Line 25-l,0+(l*2),25-l,25-(l*2)
Next 
For l = 1 To 8
	Color 50+(l*5),100+(l*5),50+(l*5)
	Line 30+l,10+l,30+l,15+l ;Right wing
	Line 20-l,10+l,20-l,15+l ;left wing
Next 

Color 20,60,20
Line 30,10,30,15 ;Right wing start
Line 20,10,20,15 ;left wing start
For l = 1 To 3
	Color 50-(l*5),100-(l*10),50-(l*5)
	Line 10+l,10+l,10+l,35-(l*3)	;left rocket
	Line 10-l,10+l,10-l,35-(l*3)
	Line 40+l,10+l,40+l,35-(l*3)	;right rocket
	Line 40-l,10+l,40-l,35-(l*3)
Next 

Color 30,30,30
For l = 1 To 5

	Line 25+Ceil(l/2),23-l,25-Ceil(l/2),23-l
Next 
Color 50,100,50
Plot 25,23
Line 25,0,25,17     ;center body
Line 10,10,10,35	;left rocket
Line 40,10,40,35	;right rocket



Next


For i = 0 To 15
	ScaleImage im(i),.75,.75
Next



SetBuffer BackBuffer()
End Function

Function Make_Beast_Images_2()
For i = 0 To 15
	im2(i) = CreateImage(50,50)
	SetBuffer ImageBuffer(im2(i))



For l = 1 To 10
	Color 80+l,60-l,60-l
	Line 23-(l/2),40-l,27+(l/2),40-l  ;nose
Next
For l = 1 To 5
	Color 80+(l*5),40-l,40-l

	Line 30,32,30,20   ;right wing
	Line 30+l,32+l,30+l,20-l
	Line 20,32,20,20   ;left wing
	Line 20-l,32+l,20-l,20-l
Next 
For l = 1 To 5
	Color 75+(l*10),20+l,55+l
	Line 45,27,45,20
	Line 45-l,27+l*2,45-l,20-l*2 ;right outer wing
	Line 5,27,5,20
	Line 5+l,27+l*2,5+l,20-l*2 ;left outer wing
Next 
For l = 1 To 3
	Color 120,120-(l*10),120-(l*10)
	Line 38-l,40-l,38-l,10+l*2;right rocket
	Line 38+l,40-l*2,38+l,10-l*2
	Line 12-l,40-l,12-l,10-l*2;left rocket
	Line 12+l,40-l,12+l,10+l*2
Next
Color 140,125,125
Line 38,40,38,10  ;rocket highlights
Line 12,40,12,10
For l = 1 To 7
	Color 20+(l*2),20+(l*2),20+(l*2)
	Line 23-(l/2),38-l,27+(l/2),38-l  ;cockpit
Next
For l = 1 To 4
	Color 120,120-(l*10),120-(l*10)
 	Line 25-l,30,25-l,15-Floor(l*1.75)
	Line 25+l,30,25+l,15-Floor(l*1.75)
Next 
Color 140,125,125 
Line 25,30,25,15
Next 

For l = 0 To 15
	ScaleImage im2(l),.65,.65
Next 

End Function 

Function Make_Base_Image()
base_im = CreateImage(64,32)
MaskImage base_im,255,0,255
SetBuffer ImageBuffer(base_im)
Color 64,64,64
Rect 0,0,64,64,True
Color 255,0,255
For s = 0 To 15
	Line s,0,0,15-s
	Line 48+s,0,64,s
Next
End Function

Function Make_Bases()
For i = 0 To 3
	bases(i) = CopyImage(base_im)
	MaskImage bases(i),255,0,255
Next	
End Function

Function Make_Bombs1()
SetBuffer ImageBuffer(bomb_im1)
Color 0,255,0
For i = 0 To 31 
	If i And 1 Then Plot 0,i Else Plot 1,i
Next 
End Function

Function Make_Bombs()
For frame = 0 To 15

	SetBuffer ImageBuffer(bomb_im,frame)

	midx = ImageWidth(bomb_im)/2;+Rnd(-3,3)
	midy = ImageHeight(bomb_im)/2;+Rnd(-3,3)
	
	
	;TFormFilter 
	

	;Color 255,0,0
	For l = 0 To 200
		;Plot Rnd(ImageWidth(Quazar_im)),Rnd(ImageHeight(Quazar_im))
		Color Rnd(225,255),Rnd(225),Rnd(0,25)
		;Color 255,255,0
		;Color 0,255,0


		;Line midx,midy,Rnd(-(midx+fr),midx+frame),Rnd(-(midy+frame),midy+frame)
		Line midx,midy,Rnd(midx-10,midx+10),Rnd(midy-10,midy+10)
		;Color 255,255,250


		;Line midx,midy,Rnd(-(midx+fr),midx+frame),Rnd(-(midy+frame),midy+frame)
		;Line midx,midy,Rnd(midx-10,midx+10),Rnd(midy-10,midy+10)


		Color 205,205,255
		Plot midx+Rnd(-1,1),midy+Rnd(-1,1)
			
	Next
	;Goto skipthis

	If frame < 7 Then 
	For l = 0 To 10
		;Plot Rnd(ImageWidth(Quazar_im)),Rnd(ImageHeight(Quazar_im))
		;Color Rnd(25,255),Rnd(25,255),Rnd(205,255)
		Color 55,255,0
		Line midx,midy,Rnd(midx-15,midx+15),Rnd(midy-15,midy+15)
		


		;Line midx,midy,Rnd((midx-frame),(midx+frame)),Rnd(-(midy+frame),(midy+frame))
		;Color 205,205,255
		;Plot midx+Rnd(-1,1),midy+Rnd(-1,1)
			
	Next
	EndIf
	If frame < 10 Then 
	For l = 0 To 10
		;Plot Rnd(ImageWidth(Quazar_im)),Rnd(ImageHeight(Quazar_im))
		;Color Rnd(25,255),Rnd(25,255),Rnd(205,255)
		Color 10,255,10
		Line midx,midy,Rnd(midx-15,midx+15),Rnd(midy-15,midy+15)
		


		;Line midx,midy,Rnd((midx-frame),(midx+frame)),Rnd(-(midy+frame),(midy+frame))
		;Color 205,205,255
		;Plot midx+Rnd(-1,1),midy+Rnd(-1,1)
			
	Next
	EndIf 
 
	;.skipthis
	;.skipthis
	For l = 0 To 40
		;Plot Rnd(ImageWidth(Quazar_im)),Rnd(ImageHeight(Quazar_im))
		;Color Rnd(5,255),Rnd(5,255),Rnd(205,255)
		Color 0,0,0
		Line midx,midy,Rnd(midx-5,midx+5),Rnd(midy-5,midy+5)
		If l=>1 Then 
			Line midx,midy,Rnd(midx-8,midx+8),Rnd(midy-8,midy+8)
		EndIf 
		If l=>1 Then 
			Line midx,midy,Rnd(midx-15,midx+15),Rnd(midy-15,midy+15)
		EndIf 

		;Line midx,midy,Rnd(midx-10,midx+10),Rnd(midy-1,midy+1)
		;Line midx,midy,Rnd(midx-2,midx+2),Rnd(midy-10,midy+10)
		;Line midx,midy,Rnd(midx-10,midx+10),Rnd(midy-1,midy+1)

		;Line midx+l,midy+l,Rnd(midx-10,midx+10),Rnd(midy-10,midy+10)
		;Line midx-l,midy-l,Rnd(midx-10,midx+10),Rnd(midy-10,midy+10)


		;Line midx,midy,Rnd(-(midx+frame),midx+frame),Rnd(-(midy+frame),midy+frame)
		;Color 205,205,255
		;Plot midx+Rnd(-1,1),midy+Rnd(-1,1)
			
	Next
	;.skipthis
	
	;center
	funct_used = funct_used+1
	Color 200+frame*3,200+frame*3,200+frame*3
	Color 255,55,200
	Plot midx,midy+1
	Plot midx+1,midy
	Plot midx-1,midy  
	Plot midx,midy-1
	Color 20+frame*10,255+frame*10,255
  	Color 255,0,0
	;lite rays******************************************************
	Plot midx+frame,midy
	Plot midx+frame/2,midy 
	
	
	Plot midx,midy+frame
	Plot midx,midy+frame/2 
	;Color 255,255,255
	Plot midx,midy-frame
	Plot midx,midy-frame/2 
	

	Plot midx-frame,midy
	Plot midx-frame/2,midy 
	
	;diagonals
	Color 20,20,255
	Color 255,0,0
		Plot midx+frame,midy+frame
		Plot midx-frame,midy-frame
		Plot midx-frame,midy+frame
		Plot midx+frame,midy-frame
	Color 20,20,255
	Color 255,0,0	
		Plot midx+frame/2,midy-frame/2;tn
		Plot midx+frame/2,midy+frame/2;to
		Plot midx-frame/2,midy-frame/2;th
 		Plot midx-frame/2,midy+frame/2;th 
	Plot midx+frame/3,midy 
	Plot midx+frame/4,midy
	Plot midx,midy+frame/3 
	Plot midx,midy+frame/4
	Plot midx,midy-frame/3 
	Plot midx,midy-frame/4
	Plot midx-frame/3,midy 
	Plot midx-frame/4,midy
	;diagonals end
	;Color 255,255,255

	
	
	;endof lite rays*********************
	
	;MaskingMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
	Color 0,0,0
	;Oval midx,midy,3+frame,3+frame,1
	;Oval midx-4+frame,midy-4+frame,9-frame,9-frame,1
	Oval -4,-4,ImageWidth(Quazar_im)+8,ImageHeight(Quazar_im)+8,0
	Oval -3,-3,ImageWidth(Quazar_im)+6,ImageHeight(Quazar_im)+6,0
	Oval -2,-2,ImageWidth(Quazar_im)+4,ImageHeight(Quazar_im)+4,0
	Oval -1,-1,ImageWidth(Quazar_im)+2,ImageHeight(Quazar_im)+2,0
	Oval 0,0,ImageWidth(Quazar_im),ImageHeight(Quazar_im),0
	;Oval 0,0,ImageWidth(Quazar_im),ImageHeight(Quazar_im),0
	
	Color 0,0,0
	;Color 2,255,255	; blue 1
	Oval -6,-6,14,14,1
	;Color 255,255,255	
	Oval ImageWidth(Quazar_im)-5,-4,15,14,1 ;white 2
	;Color 2,255,25	
	Oval midx+3,midy+3,15,15,1 ;green 3
	;Color 2,55,0	
	;Oval -5,midy-5,-12,-12,1
	Oval -5,midy+5,15,15,1

	
	;Oval -7,-7,15,15,1
	;Oval ImageWidth(Quazar_im)-5,-5,10,10,1
	;Oval midx+5,midy+5,10,10,1
	;Oval -5,midy+5,10,10,1

	;MaskingMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
	;For l= 0 To 1
		;Color Rnd(255),Rnd(255),Rnd(255)
		;Plot midx+Rnd(-1,1),midy+Rnd(-1,1)
	;Next 
;DebugLog frame
;SetBuffer ImageBuffer(Quazar_im,frame)
	
	;ResizeImage Quazar_im,frame,frame
	;
	

Next

;For frame = 0 To rotations - 1 
		;rot_im_array(frame) = CopyImage(bitmap)
		;RotateImage rot_im_array(frame), frame * 360/rotations
		;DebugLog "rotations "+ rotations
		
	;Next
 
For r = 9 To 10  
SetBuffer ImageBuffer(Quazar_im,r)

	


	angle# = r
	If angle# > 359 angle#=0 
	;ResizeImage bomb_im,5.0*f,5.0*f
	RotateImage bomb_im,angle#
	DrawImage bomb_im,midx,midy,angle#
	
Next

;For f = 14 To 15  

	;SetBuffer ImageBuffer(bomb_im,f)
	;angle# = f 
	;ResizeImage bomb_im,5.0*f,5.0*f
	;RotateImage bomb_im,-angle#
	
;Next 
 

;For f = 0 To 15  

	;SetBuffer ImageBuffer(bomb_im,f)
	;angle# = f 
	;If f > 12
		;ResizeImage bomb_im ,20,30
	;EndIf 
	;RotateImage bomb_im,angle#
	
;Next 









End Function


;BULLET********************BULLETS*********************BULLETS****************************BULLETS
Function Make_Bullets_im() ;standard bullets
SetBuffer ImageBuffer(bullet_im)
midx=ImageWidth(bullet_im)/2
midy=ImageHeight(bullet_im)/2

Color 255,100,200
;For i = 0 To 8
	;Plot midx,midy+i
	;Plot midx,midy-i
		
;Next 
Color 255,0,0

For i = 0 To 6 
	
	Plot midx+1,midy+i
	
	Plot midx+1,midy-i
	Plot midx-1,midy+i
	Plot midx-1,midy-i
	
Next 
Color 0,0,0
;Line midx,midy-5,midx+1,midy
;Line midx,midy+5,midx+1,midy
;Line midx,midy-5,midx-1,midy
;Line midx,midy+5,midx-1,midy
;Line midx,midy-9,midx,midy+9
;Color 255,0,0
;Plot midx,midy 
End Function

Function Make_rappedfire() ;rappedfire bullets+++
For frame = 0 To 15
	;rappedfire_im = CreateImage(6,24,4)
	SetBuffer ImageBuffer(rappedfire_im,frame)
	midx = ImageWidth(rappedfire_im)/2
	midy = ImageHeight(rappedfire_im)/2

	Color 255,0,0
	Line midx,0,midx,24
	Color 170,0,20
	Line midx-1,0,midx-1,24
	Color 170,0,20
	Line midx+1,0,midx+1,24

	Color 255,120,105
	For i=0 To 4

		Color 255,220,205
		burnhole_y=Rnd(ImageHeight(rappedfire_im))
		Plot midx,burnhole_y
		Color 0,0,0
		Plot midx,burnhole_y+1
		Plot midx,burnhole_y+2

	
	Next 

;Color 0,0,0
;For i=0 To 10
	;Plot midx,Rnd(ImageHeight(rappedfire_im))
;Next 


	For l=0 To 5
		burnhole_y=Rnd(ImageHeight(rappedfire_im))
		Color 0,0,0

		Plot midx-1,burnhole_y
		Plot midx+1,burnhole_y
	
		Plot midx+1,burnhole_y-1
		Plot midx+1,burnhole_y+1

	
	Next 
	;+++ sparkly head of rapedfire bullet
	For l = 0 To 20
	Color Rnd(100,200),Rnd(100,200),0
		;Color 255,255,0
		Plot midx+Rnd(-4,4),midy - (ImageHeight(rappedfire_im)/2) + Rnd(-6,6)
	
	Next
	For l = 0 To 40
		Color Rnd(200,255),Rnd(200,255),Rnd(100,255)
		;Color 255,255,0
		Plot midx+Rnd(-3,3),midy - (ImageHeight(rappedfire_im)/2) + Rnd(-3,3)
	
	Next
Next 

 
End Function