Beginners Community Project - Space Invaders

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

*** Please could a moderator make this sticky ***

Below is the skeleton code for a space invaders clone that I am giving to the Blitz Beginners Community as a starting point for development. It's completely self-contained and fairly self-explanatory - I'll comment it soon, promise.

The idea here is three-fold:
1) That people can see how certain things are done(eg, there are very basic particle and parallax effects);
2) That the Blitz Community can develop it into a complete game, ie, give it intro screens, player lives, level, etc, so that others can use it to learn how to make a complete game;
3) Finally, that reusable community code is developed so that people don't have to reinvent the wheel every time they want a high-score table, etc.

One final caveat - all code developed remains completely public domain meaning that you're not allowed to make claims on any code provided(the same goes for me too). It's meant as a development mechanism for everyone - everyone is free to contribute and everyone is free to take what they want(giving credits where due). The idea is not to make money from this, it's to enable people to learn how to program(and then make money).

Any comments welcome.

UPDATED 18/NOV/2005

Now in place are Riverratts graphics.
Also in place are Becky Roses sound functions - anyone want to add extra sounds, that'd be groovy (for alien shots and alien, player and mothership explosions)

I've added:
A high score table
Levels
Lives and extra lives
Intro screen, level screen and game over screen.
Bonuses - Really exciting :0)
Anything else needed?

Gosub makeSound

Type Control_Type
	Field Max_Bombs
	Field Bomb_Speed
	Field Crit_Drop_Speed
	Field drop_bomb_chance
	Field Player_StartSpeed
	Field Player_Speed
	Field Bullet_Speed
	Field Max_Rows
	Field Max_Cols
	Field XRes, YRes, Depth
	Field Beast_Speed#
	Field Beast_Speed_Increment#
	Field UFO_Speed
	Field Level
	Field NextExtraLife
End Type

Type points_type
	Field x,y
	Field id
End Type

Type explosion_type
	Field x,y
	Field speed
	Field status
	Field dirx,diry
	Field count
	Field id
End Type

Type HighScoreTable_Type
	Field score
	Field name$
End Type

Dim HighScores.HighScoreTable_type(10)
Global highscore.highscoretable_type
Dim SpaceyFont(40)

Type Player_Type
	Field x,y
	Field moved
	Field lives
	Field score
	Field Shield_Active
	Field Shield_Timer#
	Field Non_Expiring_Shot
	Field NES_Timer# ; Non-expiring shot timer
	Field Cluster
	Field Cluster_Timer#
	Field Speedy
	Field Speedy_Timer#
End Type

Type stars_type
	Field image
	Field x,y
	Field count
End Type

Type Beast_Type
Field x#,y#
Field deleted
End Type

Type Bullet_Type
	Field fired
	Field x,y
End Type

Type Bomb_Type
	Field fired
	Field x,y
	Field deleted 
End Type

Type UFO_Type
	Field x,y
	Field status
End Type

Type Bonus_Type
	Field active
	Field x,y
	Field frame
	Field frametimer#
End Type

;*********************************
; Create and Set up Control Type
; This is used to manage all our game control variables,
; it's easier keeping them in one place and putting the set up at the start means we can 
; control the details in the rest of the set up from here on in

Global control.Control_Type
Set_Up_Control

; Set graphics size
Graphics control\xres,control\yres,control\depth
AutoMidHandle True

Dim im(15)
Dim bases(3)
Dim Points_Ims(16)
Dim debri(16)
Dim stars.stars_type(3)

Global bim 
Global ufo_im
Global ship_im 
Global bonus_im
Global base_Im
Global bomb_im = CreateImage(2,32)
Global xp,yp
Global blank_im = CreateImage(6,24)
Global point.points_Type
Global bullet_im = CreateImage(2,16)
Global dir# = control\beast_speed
Global score = 0
Global beast_count, total_beasts
Global x#, y#
Global EndGame = False
Global char$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 @#~"

Global explosion.Explosion_type
Global player.Player_Type
Global beast.Beast_Type
Global bullet.bullet_type
Global bombs.bomb_type
Global ufo.ufo_type = New ufo_type
Global Bonus.Bonus_type = New Bonus_type
player.Player_Type = New Player_Type	; create player

Make_Base_Image
Make_Bonus_Images
Make_Collision_Image
Make_Player_Image
Make_Beast_Images
Make_Beasts
Make_Bases
Make_Points_Ims
Make_Blank
Make_Bombs
Make_Bullets
Make_Debri
Make_Stars
Make_Ship
Make_Ufo
Make_Player
Make_Bullet
Make_HighScoreTable
Make_SpaceyFont

SetBuffer BackBuffer()

quit = displaystartscreen()

While quit = False

	endgame = False
	
	old_level = 0 : control\level = 1 : control\nextextralife = 2500
	make_player	
	While endgame = False

		If old_level <> control\level Then
			Introduce_Level
			StartNewLevel
			old_level = control\level
		End If
		
		If player\lives<=0 Then endgame =True 
		
		time# = MilliSecs()
		
		If player\score > control\nextextralife Then
			control\nextextralife = control\nextextralife + 2500
			player\lives = player\lives + 1
		End If

		Move_stars	
		Display_Info
		af = (af + 1) And 15
	
		min_x = control\xres
		max_x = 0

		new_ufo
		If ufo\status = True Then move_ufo

		bomb_count = 0
		For bombs = Each bomb_type
			bomb_count = bomb_count + 1
			DrawImage bomb_im,bombs\x,bombs\y
			bombs\y = bombs\y + control\bomb_speed
		
			If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(0),192,400,0) Then
				SetBuffer ImageBuffer(bases(0))
				Color 0,0,0
				bxp = bombs\x - 168
				byp = bombs\y -368
				draw_blank bxp,byp
				SetBuffer BackBuffer()
				Delete bombs
				bomb_count = bomb_count-1
			ElseIf ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(1),320,400,0) Then
				SetBuffer ImageBuffer(bases(1))
				Color 0,0,0
				bxp = bombs\x - 288
				byp = bombs\y -368
				draw_blank bxp,byp	
				SetBuffer BackBuffer()
				Delete bombs
				bomb_count = bomb_count-1
			ElseIf ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(2),448,400,0) Then
				SetBuffer ImageBuffer(bases(2))
				Color 0,0,0
				bxp = bombs\x - 420
				byp = bombs\y -368
				draw_blank bxp,byp
				SetBuffer BackBuffer()
				Delete bombs
				bomb_count = bomb_count-1
			ElseIf ImagesCollide(bomb_im,bombs\x,bombs\y,0,ship_im,player\x,player\y,0) Then
				If player\shield_Active = False Then
					bomb_count=bomb_count-1
					Player\lives = player\lives-1
					For i = 0 To 10
						ClsColor Rnd(255),Rnd(255),Rnd(255)
						Cls
						Flip
					Next
				End If
				Delete bombs
			Else If bombs\y > 480 Then
				Delete bombs : bomb_count=bomb_count-1
			End If
			
		Next

	
		check_bullets_and_bases
	
		player\moved = False
		
		If MilliSecs()>player\shield_timer + 5000 Then
			player\shield_active = False
		Else
			Text 0,128,"Shield Active"
		End If
		
		If MilliSecs()>player\NES_Timer + 5000 Then
			player\Non_Expiring_Shot = False
		Else
			Text 0,144,"Non Expiring Shots"
		End If 
		
		
		If MilliSecs()>player\cluster_timer + 5000 Then
			player\cluster = False
		Else
			Text 0,160,"Cluster Fock"
		End If
		
		If MilliSecs()>Player\Speedy_Timer + 5000 Then
			control\player_speed = control\player_startspeed
			player\speedy = False
		Else
			Text 0,176,"Speedy"
		End If
		
		bomb_dropped = False
	
		beast_hit = False

		dokeys

		beast_count = 0
		For beast = Each beast_Type
			If beast\deleted = False Then
				beast_count = beast_count + 1
				x = beast\x + dir : y = beast\y
				If inc_y = True Then y = y + control\crit_drop_speed
				If dir > 0 Then
					If x > max_x Then max_x = x
				Else
					If x < min_x Then min_x = x
				EndIf
				
				If ImagesCollide(im(af), beast\x,beast\y,0,bases(0),192,400,0) = True Then 
					FreeImage bases(0) : bases(0) = CreateImage(1,1)
				Else If ImagesCollide(im(af), beast\x,beast\y,0,bases(1),320,400,0) = True Then
					 FreeImage bases(1) : bases(1) = CreateImage(1,1)
				Else If ImagesCollide(im(af), beast\x,beast\y,0,bases(2),448,400,0) = True Then
					FreeImage bases(2) : bases(2) = CreateImage(1,1)
				End If				
				beast\x = x
				beast\y = y

				DrawImage im(af),beast\x, beast\y
	
				If bullet\fired = True Then
					If ImagesCollide(im(af),beast\x,beast\y,0,bim,bullet\x,bullet\y,0) Then

						Add_Point beast\x , beast\y
						player\score = player\score + 10
					
						beast_count = beast_count-1 : beast_hit = True
					
						Make_Explosion beast\x,beast\y,5	
									
						beast\deleted = True
						
						If player\cluster = True Then 
							bullet\x = bullet\x + (Rand(128)-64)
							bullet\y = bullet\y + (Rand(128)-64)
						Else If player\non_expiring_shot = False Then 
							bullet\fired = False
						End If
						
					EndIf
				EndIf
			
				If bomb_dropped = False Then
					If bomb_count < control\max_bombs Then
						If Rand(100)<control\drop_bomb_chance Then
							bomb_count = bomb_count+1
							bomb_dropped = True
							bombs = New bomb_type
							bombs\x = beast\x : bombs\y = beast\y
						EndIf
					EndIf
				EndIf
				
			EndIf
			
			If beast\y > 460 Then endgame = True
		Next
	
		If beast_hit = True Then Increase_Beast_Speed
  
		inc_y = False
		If dir >0 Then
			If max_x > 608 Then dir = -dir : inc_y = True
		Else
			If min_x < 32 Then dir = - dir : inc_y = True
		EndIf

		Do_Points	
		DoExplosion
		Move_Bonus_Item
		If ufo\status = True Then Check_Bullets_And_Ufo
		Move_And_Draw_Bullet
	
		If beast_count = 0 And ufo\status = False Then control\level = control\level + 1
		
		DrawImage ship_im,player\x,player\y

		DrawImage bases(0),192,400
		DrawImage bases(1),320,400
		DrawImage bases(2),448,400
	
		Color 255,255,255
	
		Flip
	Wend
	
	DisplayEndScreen
	EnterHighScore
	endgame = False
		
	Delay(500)
	FlushKeys
	
	quit = displaystartscreen()	
Wend
End

Function Set_Up_Control()
control.Control_Type = New Control_Type
control\max_bombs = 4
control\bomb_speed = 4
control\crit_drop_Speed = 4
control\drop_bomb_chance = 5
control\player_StartSpeed = 4
control\player_speed = control\player_StartSpeed
control\bullet_speed = 24
control\max_rows = 7
control\max_cols = 11
control\xres = 640 ; Try this pair at different resolution: 640,480 or 1024,768 or 1280,1024
control\yres = 480; 
control\depth = 16;
control\level = 1
control\Beast_Speed = 1
control\Beast_Speed_Increment = 0.05
control\UFO_Speed = 4
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
	If bullet\fired = False Then
		bullet\x = player\x : bullet\y = 460
		bullet\fired = True
		PlaySound shootsound
	EndIf
EndIf

If player\moved = False Then
	If KeyDown(205) Then
		If player\x < 608 Then player\x = player\x + control\player_speed : player\moved = True
	EndIf
		
	If KeyDown(203) 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(2))-1
			explosion\diry = Int(Rand(2))-1
			explosion\status = 1
			explosion\count = 10
		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
End Function

Function Check_Bullets_And_UFO()
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
End Function

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

Function Check_Bullets_And_Bases()
	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 - 384
				draw_Blank xp,yp
				SetBuffer BackBuffer()
			EndIf
			If bullet\fired = False Then Exit
		Next

		If bullet\y < 0 Then 
			bullet\fired = False
		EndIf
	EndIf
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()

	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
	If Rand(100) < 10 Then
		ufo\status = True
		ufo\x = 640
		ufo\y = 32
	EndIf
EndIf

End Function

Function Move_Ufo()
	ufo\x = ufo\x - control\ufo_speed
	If ufo\x < 0 Then
		ufo\status = False
	EndIf
	DrawImage ufo_im,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 = CreateImage(16,16)
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 Make_Bullet()
; This creates the players bullet used throughout the whole game
	bullet = New bullet_type	; create bullet
	bullet\fired = False		; set that it's not been fired
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
	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
		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)
		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
	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_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_Bombs()
SetBuffer ImageBuffer(bomb_im)
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_Bullets()
SetBuffer ImageBuffer(bullet_im)
Color 0,255,255
For i = 0 To 15
	If i And 1 Then Plot 0,i Else Plot 1,i
Next 
End Function

Function Make_Ufo()
	ufo_im = CreateImage(100,100)
	;Color 0,255,0
	SetBuffer ImageBuffer(ufo_im)
	;rockets
For i = 1 To 3
	Color 75-(10*i),75,75-(10*i)
	Line 25+i,60,25+i,95-(i*5) ;left rocket
	Line 25-i,60,25-i,95-(i*5)
	Line 75+i,60,75+i,95-(i*5) ;right rocket
	Line 75-i,60,75-i,95-(i*5)
Next
Line 25,60,25,70
Line 75,60,75,70
Color 175,75,75
Line 25,65,25,95
Line 75,65,75,95
;mid section
For i = 1 To 4 ;neck
 	Color 40,80,40
	Line 50+i,20+(i*7),50+i,100-(i*7) 
	Line 50-i,20+(i*7),50-i,100-(i*7)
Next 
For i = 1 To 4 ;neck highlight
	Color 70,100,70
	Line 50+i,20+(i*7),50+i,90-(i*7) 
	Line 50-i,20+(i*7),50-i,90-(i*7)
Next 
For i = 1 To 3
	Line 50+i,0+(i*10),50+i,60 
	Line 50-i,0+(i*10),50-i,60
Next
 
;wings
For i = 1 To 25
	Color 55+i,75+(i*2),25+i
	Line 50-i,40+i,50-i,60+i
	Line 50+i,40+i,50+i,60+i
Next 
;wing tips
Line 75,65,75,84
Line 25,65,25,84
For i = 1 To 25
	;Color 125-i,150-i,125-i
	Color 80-i,130-(i*3),50-i
	Line 75+i,65-i,75+i,85-Ceil(i*1.75)
	Line 25-i,65-i,25-i,85-Ceil(i*1.75)
Next 
;head
Color 30,80,30
For i = 1 To 10
	Line 50+Ceil(i/2),100-i,50-Ceil(i/2),100-i ;forhead
Next 
For i = 1 To 5
	Line 45+i,90-i,55-i,90-i 
Next
Color 25,25,25
For i = 1 To 5
	Line 50+Ceil(i/2),97-i,50-Ceil(i/2),97-i ;forhead
Next 
Color 175,75,75
Line 50,0,50,10 
;center body and rocket centers
Color 50,70,20
Line 50,38,50,63 ;wings center line
Color 70,90,70
Line 50,10,50,86
For i = 1 To 75 Step 6
Color 175-i,75-i,75-i
Plot 50,0+i
Next 
Color 70,90,70
Line 51,56,75,80
Line 49,56,25,80
Line 90,55,75,80
Line 10,55,25,80

ScaleImage ufo_im,.5,.25
RotateImage ufo_im,90	
End Function

Function SpaceyText(x,y,message$,centre)
If Len(message)>0 Then
	If centre = True Then
		length = Len(message) * ImageWidth(spaceyfont(0))
		xs = (640-length)/2
	Else
		xs = x
	End If
	
	For c = 1 To Len(message)
		v = 0
		ch$ = Mid$(Upper(message), c, 1)
		If ch>="0" And ch<="9" Then 
			v = 26 + Asc(ch)-48
		Else If ch>="A" And ch<="Z" Then 
			v = Asc(ch)-65
		Else
			v = 36
		End If
		
		DrawImage spaceyfont(v),xs + (c * ImageWidth(spaceyfont(0))), y
	Next			
End If
End Function

Function Make_Bonus_Images()
Bonus_im = CreateImage(64,16,8)
For i = 0 To 7
	SetBuffer ImageBuffer(bonus_im,i)
	ClsColor i Shl 5,0,0
	Cls
	Color 64,192,64
	Rect 0,0,64,16,False
	Text 8,2,"BONUS"
	SetBuffer BackBuffer()
Next
End Function

Function Move_Bonus_Item()
If bonus\active = True Then
	bonus\y = bonus\y + 4
	If MilliSecs() > bonus\frametimer + 100 Then
		bonus\frame = (bonus\frame + 1) And 7
		bonus\frametimer = MilliSecs()
	End If
	DrawImage bonus_im,bonus\x, bonus\y, bonus\frame
	If ImagesCollide(bonus_im, bonus\x,bonus\y,0, ship_im, player\x, player\y,0) Then
		bonus\active = False
		Choose_Bonus_Type
	End If
	If bonus\y > 600 Then bonus\active = False
End If
End Function

Function Choose_Bonus_Type()
bt = Int(Rand(6))+1
Select bt
	Case 1
		; Shield
		player\Shield_Active = True
		player\Shield_Timer = MilliSecs()
	Case 2
		; Non-expiring shot
		Player\Non_Expiring_Shot = True
		Player\Nes_Timer = MilliSecs()
	Case 3
		; Speed
		Player\Speedy = True
		Player\Speedy_Timer = MilliSecs()
		control\Player_speed = control\Player_StartSpeed Shl 1
	Case 4
		; Cluster fock
		Player\cluster = True
		Player\Cluster_timer = MilliSecs()
	Case 5
		; Rebuild bases
		Make_Bases		
	Case 6
		player\lives = player\lives + 1
		; Extra Life
End Select

End Function

;Becky Roses wierd way of doing sound in code
.shoot
Data 4810
Data 82,73,70,70,194,18,0,0,87,65,86,69,102,109,116,32,18,0,0,0,1,0,1,0,64,31,0,0,64,31,0,0,1,0,8,0,0,0,102,97,99,116,4,0,0,0,143,18,0,0,100,97,116,97,143,18,0,0,126,163,97,101,124,137
Data 134,110,112,120,154,131,117,116,152,132,141,155,80,104,221,66,135,200,59,112,244,129,56,188,155,61,114,208,47,88,198,89,59,162,204,46,109,207,113,84,189,194,40,111,234,125,51,146,215,68,72,202,156,43,97,207,127,88,109,205,90,93,121,204
Data 89,87,127,220,84,85,133,211,84,93,122,200,88,79,115,193,116,70,94,177,164,64,73,160,214,61,60,138,207,126,54,95,161,210,79,49,135,199,148,77,76,136,210,159,38,91,170,192,141,58,107,136,197,143,41,83,146,209,145,64,80,142,186,199
Data 100,63,121,150,205,143,43,88,142,180,188,82,41,95,163,199,191,92,57,113,153,184,181,81,41,112,145,183,205,113,36,104,128,162,203,152,73,60,117,143,182,191,129,45,52,118,160,178,185,153,48,51,131,139,168,193,153,93,44,89,148,152,172,188
Data 140,73,48,100,144,161,171,191,160,88,41,78,136,159,155,183,182,149,69,43,93,139,153,155,183,178,163,88,36,81,114,155,158,155,179,172,146,76,43,50,121,155,159,164,160,170,169,142,78,38,52,103,151,166,159,157,160,166,160,140,83,38,55,82
Data 142,165,162,163,147,154,165,154,145,114,55,44,53,103,148,168,169,161,155,145,145,156,151,144,125,106,60,49,58,85,134,156,174,171,161,158,145,140,136,143,148,140,132,119,116,34,28,111,226,100,125,185,106,178,115,102,160,91,132,162,107,188,85,106
Data 102,96,186,91,163,121,92,179,86,150,130,92,163,88,155,126,92,153,87,174,104,146,124,92,194,87,180,92,98,100,95,198,79,201,79,126,144,121,152,88,192,88,195,83,112,81,113,151,87,147,90,201,82,204,82,144,112,97,101,100,177,86,157,89
Data 203,83,198,84,178,91,195,86,142,107,170,93,118,130,147,103,109,147,135,111,103,156,125,107,92,154,115,109,99,149,92,104,107,136,98,99,122,113,105,90,144,98,127,85,187,90,168,87,207,85,210,97,160,94,171,119,104,118,110,188,86,184,86,184
Data 88,179,89,106,120,101,124,96,203,84,207,87,126,106,111,114,86,200,85,205,101,118,113,86,201,83,203,103,106,121,97,204,86,174,92,97,164,90,205,98,120,114,100,161,88,163,97,115,199,85,197,93,101,174,90,209,108,106,163,90,147,106,104,157
Data 81,134,102,100,199,88,122,121,84,173,97,110,210,88,134,113,89,177,101,109,171,89,121,132,95,142,113,100,212,101,106,198,86,110,177,86,157,158,86,168,101,88,170,98,102,171,97,104,208,98,100,210,85,101,209,92,112,192,92,107,208,85,102,207
Data 87,110,179,95,104,205,116,95,169,105,87,134,135,91,117,197,83,121,203,92,105,203,121,92,143,128,84,118,204,82,103,172,106,99,153,189,82,119,209,106,99,147,126,78,112,203,84,88,129,162,84,106,171,107,94,124,210,86,108,130,189,83,117,144
Data 146,87,124,164,117,90,129,185,105,93,129,202,96,97,131,203,96,97,130,206,100,94,126,210,108,90,125,196,135,81,121,166,182,75,113,143,211,85,101,131,169,115,85,122,137,195,78,105,126,176,109,85,123,136,208,79,103,124,150,158,79,103,130,176
Data 116,76,112,135,193,152,77,116,137,159,142,77,114,129,156,155,73,101,132,144,192,87,91,127,140,205,126,72,112,131,137,194,70,98,122,137,168,131,69,102,133,140,162,148,73,114,130,140,172,135,72,99,131,141,143,201,70,96,122,139,140,193,153,67
Data 107,133,140,138,195,85,80,112,134,141,139,184,98,74,118,132,139,138,175,169,64,100,132,140,141,135,189,135,67,108,132,138,139,136,176,159,62,99,129,138,139,138,142,184,105,71,114,137,140,141,135,135,167,131,67,107,128,140,138,136,136,133,172,109
Data 65,98,129,140,140,138,134,134,132,167,116,65,94,130,137,134,132,129,128,127,133,159,132,64,99,123,140,141,137,138,134,130,129,129,134,163,117,65,90,128,140,141,139,136,133,133,129,130,127,127,127,144,156,119,63,94,130,141,143,131,120,121,123,130
Data 115,113,115,119,121,113,112,114,130,119,118,118,139,127,125,126,139,122,124,121,132,118,121,115,140,126,124,126,129,118,118,114,124,122,136,127,121,120,128,124,115,132,119,146,118,125,118,143,125,147,126,136,120,145,116,126,125,121,131,112,132,113,157,124
Data 145,121,141,132,133,122,119,130,126,121,115,162,111,129,157,116,99,141,114,93,156,134,124,119,166,105,113,167,126,113,138,161,105,124,157,110,115,147,154,100,112,153,97,122,135,155,95,136,154,112,108,138,159,101,105,153,144,121,111,166,141,96,120,148
Data 139,98,115,161,131,109,124,158,151,95,137,155,143,105,109,170,150,98,108,137,169,107,97,134,155,134,96,119,159,150,111,108,133,173,129,95,126,132,166,116,93,132,148,143,96,98,129,154,143,118,96,128,158,150,112,104,129,153,154,111,108,125,142,162
Data 124,111,104,126,168,134,102,103,119,147,158,131,98,109,124,150,158,121,100,109,132,158,159,128,101,111,125,155,158,129,113,98,122,146,152,151,115,96,115,136,144,154,139,111,92,119,137,142,159,141,100,99,105,132,145,148,150,128,91,96,127,136,143,153
Data 146,111,95,104,127,139,149,152,148,128,92,92,123,137,139,149,156,141,110,90,99,123,138,140,144,147,145,116,96,98,115,135,138,141,147,147,150,123,94,93,106,129,140,142,139,147,150,139,126,94,94,109,133,142,144,141,142,149,144,135,114,100,90,102
Data 130,138,144,143,137,136,138,139,136,127,110,91,93,103,124,142,145,145,142,136,135,136,140,138,128,125,108,96,94,105,120,137,147,149,145,142,137,133,132,133,136,135,130,126,123,93,77,99,157,122,145,121,124,143,119,135,131,117,141,113,126,141,120,141
Data 115,121,124,117,141,119,119,130,115,138,122,132,131,116,140,112,134,128,117,136,114,138,119,134,125,117,144,115,144,114,122,116,120,145,111,145,111,132,127,131,128,117,147,116,146,110,130,127,131,126,118,147,119,147,112,138,113,141,115,125,113,127,129,118
Data 123,120,143,114,138,116,148,113,146,113,144,114,148,113,140,116,146,114,137,118,126,113,134,115,122,111,130,116,124,112,135,116,128,113,139,115,134,114,146,114,140,115,150,114,148,118,143,116,148,125,127,123,131,135,115,133,116,149,114,149,113,148,117,137
Data 118,136,132,117,133,115,148,113,149,113,125,125,121,145,113,148,113,132,121,125,125,114,148,113,149,121,122,127,116,150,114,147,116,135,135,115,145,114,133,123,120,132,114,148,117,132,139,114,151,114,120,132,116,148,119,126,129,117,149,117,127,128,114,148
Data 114,123,144,111,144,118,115,150,113,136,124,115,151,117,124,151,115,137,125,115,149,118,121,153,115,127,131,114,135,126,116,143,122,118,149,119,119,146,113,119,143,113,135,142,113,136,125,116,135,125,114,152,126,115,150,120,115,145,122,117,137,125,115,149
Data 131,113,139,123,113,129,133,114,122,144,113,125,154,115,119,154,122,116,148,121,113,128,135,113,128,153,114,120,155,125,115,138,129,113,123,153,114,116,140,128,114,123,156,113,117,131,130,111,124,153,117,116,138,148,112,122,154,132,113,125,154,122,115,130
Data 144,112,117,136,134,112,120,143,128,113,122,146,125,113,122,147,125,113,121,145,126,112,121,139,131,111,118,133,141,110,116,128,153,111,113,127,156,119,111,123,139,134,110,117,129,155,113,112,124,142,131,110,117,129,157,127,110,123,134,156,115,114,126,133
Data 152,111,117,125,137,146,109,113,127,137,142,113,114,126,136,147,115,113,127,133,153,122,110,124,130,142,137,106,111,125,130,154,124,107,121,130,133,155,110,113,124,132,139,145,112,111,126,132,135,155,111,112,123,131,134,156,113,107,121,131,133,139,145,106
Data 114,124,131,132,151,137,105,116,128,132,133,147,127,105,113,127,132,132,135,148,107,106,122,131,133,132,140,139,104,109,124,131,132,131,136,145,105,111,122,131,132,132,131,145,128,104,112,126,132,133,132,131,141,136,109,109,124,132,133,133,131,130,137,142
Data 106,111,122,130,133,132,132,130,130,142,130,106,109,125,131,131,130,129,128,128,127,138,135,110,106,122,131,134,133,132,131,130,128,128,129,137,139,107,108,119,130,133,133,133,132,130,129,128,127,127,127,133,139,129,104,109,121,131,134,135,128,136,126,131
Data 126,133,124,127,125,130,122,125,123,127,124,125,123,126,125,127,123,128,125,127,124,128,124,125,128,125,125,127,126,130,124,126,125,127,123,128,125,134,124,129,126,131,125,133,126,132,126,131,127,128,127,128,130,124,126,126,131,125,131,122,130,127,135,126
Data 131,127,131,129,128,130,123,129,128,129,118,137,123,118,133,127,113,124,144,112,133,144,122,121,144,134,113,142,132,117,125,144,119,112,140,127,119,134,141,116,117,143,131,120,128,142,122,115,139,127,121,120,142,121,114,132,139,122,117,131,141,114,120,136
Data 136,116,118,140,135,116,118,134,142,113,124,136,139,118,116,130,143,117,116,125,143,124,112,123,137,135,113,113,134,143,121,114,121,144,134,118,120,128,146,135,112,124,136,143,131,112,122,137,144,125,111,124,140,142,123,114,120,137,145,125,115,117,133,147
Data 138,114,115,125,137,140,120,113,116,130,145,134,118,114,122,137,147,135,114,115,121,136,146,132,120,113,123,139,145,140,123,110,121,132,140,143,127,112,113,129,135,141,146,123,108,117,126,135,145,142,126,111,112,123,134,139,141,134,113,108,122,129,135,141
Data 140,130,110,112,124,132,137,141,141,130,114,106,120,131,134,138,143,138,128,111,109,121,129,136,137,139,141,130,113,108,113,126,133,136,136,140,140,128,116,106,112,125,134,136,135,138,139,138,129,111,107,109,124,134,138,136,134,138,137,136,128,114,106,108
Data 120,132,137,137,135,133,134,135,133,129,120,111,107,111,123,131,137,138,137,133,133,132,135,134,131,127,118,110,107,111,120,131,136,139,138,137,135,133,130,131,132,132,130,127,126,118,101,107,124,134,135,125,133,127,126,132,123,129,131,122,129,122,126,132
Data 121,132,124,124,133,122,132,126,124,130,122,131,126,130,130,122,132,121,131,128,123,130,121,132,124,131,126,124,134,123,133,121,127,122,126,132,121,131,121,131,125,125,125,125,134,120,134,120,131,124,131,124,126,133,127,132,122,134,123,134,121,130,121,132
Data 123,127,122,128,129,124,126,126,133,122,135,124,135,122,134,123,135,122,134,123,135,121,133,121,133,119,130,120,134,120,133,122,135,121,134,123,135,122,136,125,134,123,136,127,129,126,131,130,124,129,125,128,121,133,121,132,122,136,122,136,126,129,125,128
Data 132,121,132,122,135,122,135,127,125,127,124,135,122,136,122,129,126,126,127,121,135,121,136,122,126,127,123,130,121,136,122,133,130,122,133,121,133,125,127,129,122,137,123,134,131,122,135,122,129,128,122,132,123,132,126,125,137,122,134,125,122,136,122,134
Data 124,120,135,121,131,132,121,137,122,122,135,122,135,131,122,138,123,122,136,122,134,132,122,137,124,122,138,123,128,136,122,131,128,122,134,127,122,137,125,122,137,121,122,136,121,128,136,121,128,130,121,126,131,121,126,133,121,132,135,121,129,130,121,125
Data 133,121,123,136,121,126,138,122,123,137,125,121,139,124,122,133,129,121,134,135,121,125,135,123,122,139,123,121,132,130,121,124,139,122,123,135,129,121,131,138,122,124,141,129,119,127,133,121,121,137,126,120,124,139,122,123,130,134,121,124,136,129,121,127
Data 140,125,121,130,141,123,122,132,139,122,122,134,138,121,123,135,138,121,122,133,138,121,122,131,140,121,121,129,141,124,120,126,141,127,119,125,139,135,119,123,131,141,122,120,127,136,130,119,124,128,140,121,120,125,135,132,119,121,127,141,125,119,123,129
Data 141,127,119,124,131,140,125,119,125,131,141,124,119,125,129,141,125,118,123,129,139,130,119,121,128,134,142,122,117,124,127,136,130,117,119,127,130,142,130,117,123,129,131,142,124,118,125,129,131,142,123,117,123,129,131,137,133,117,122,126,130,133,139,124
Data 116,124,129,130,134,136,117,117,124,129,131,133,139,118,118,123,128,130,131,139,126,116,122,129,130,131,133,136,122,116,123,129,130,130,131,138,125,115,122,128,130,130,130,135,137,118,117,125,129,130,130,130,131,138,121,116,121,128,130,131,130,129,132,137
Data 119,115,122,128,130,131,130,129,129,132,137,119,116,121,128,130,129,129,128,128,127,129,136,122,115,119,127,131,131,130,130,129,128,128,128,132,135,120,114,120,128,131,131,131,130,129,129,128,128,127,127,128,133,131,121,114,121,128,130,136,129,131,127,129
Data 127,130,127,129,126,129,127,129,126,128,126,129,126,127,126,128,126,128,126,129,126,128,126,129,125,127,126,128,126,129,126,130,126,128,127,128,126,130,127,129,127,129,128,127,127,129,128,126,128,127,127,126,129,126,128,126,129,127,129,127,130,128,130,128
Data 127,128,128,128,126,129,126,127,126,128,123,125,130,122,129,133,124,124,136,125,122,135,127,124,130,133,121,132,135,124,125,135,129,120,132,130,123,124,134,124,121,133,132,123,123,134,127,120,128,134,124,123,130,133,121,127,134,129,122,127,137,127,123,130
Data 133,128,122,131,133,125,122,129,136,126,120,130,135,128,121,126,136,129,122,125,134,135,122,123,131,135,126,119,128,135,130,122,123,128,137,125,122,125,134,134,121,123,127,135,132,120,120,131,137,129,121,121,132,136,132,122,122,130,137,133,122,121,126,136
Data 135,123,121,122,130,135,131,120,120,127,134,136,125,120,121,129,137,134,122,119,122,131,137,136,125,119,123,128,135,136,127,119,120,128,134,137,134,121,118,123,129,134,138,132,120,120,125,129,135,137,129,121,116,123,129,132,136,133,122,116,119,127,131,134
Data 136,131,120,118,121,127,132,135,136,133,122,116,118,126,131,133,135,136,130,120,116,119,127,132,132,134,136,131,125,116,118,125,130,133,133,134,135,132,123,116,117,122,129,132,132,133,134,134,130,123,116,116,123,128,133,133,132,133,134,133,129,124,117,115
Data 121,127,132,133,132,131,131,132,131,129,126,119,115,117,121,128,133,134,133,132,131,130,131,131,130,128,125,119,116,117,119,126,131,134,134,133,132,131,130,129,130,130,130,128,127,124,117,112,122,131,131,129,130,127,127,128,126,129,128,128,129,125,127,126
Data 126,129,125,129,127,126,129,125,129,127,126,128,125,129,127,128,128,125,129,125,129,127,125,128,125,129,126,127,127,126,130,124,130,125,128,128,127,129,125,130,125,129,126,127,126,127,129,125,129,125,129,125,130,125,128,128,128,128,126,130,126,130,125,130
Data 125,130,125,129,127,129,126,128,129,128,127,127,130,128,129,126,130,127,129,126,131,127,130,125,129,126,129,125,130,126,129,126,130,127,129,126,130,128,128,127,129,127,126,129,127,128,125,130,125,129,125,131,125,130,126,130,126,127,128,127,128,125,130,125
Data 130,125,130,126,130,128,126,128,125,130,125,130,125,131,127,127,128,126,130,125,131,125,127,128,126,129,125,131,125,130,128,125,130,125,130,126,128,127,125,131,125,131,128,125,130,125,130,127,127,129,125,131,126,128,128,125,132,126,129,130,125,131,126,125
Data 130,124,130,127,124,130,124,127,128,124,131,127,126,130,125,128,129,125,132,127,126,131,125,127,129,125,132,126,125,132,126,128,132,125,129,129,125,130,128,124,130,128,124,132,127,124,132,125,124,132,125,126,132,125,125,131,126,125,132,125,125,132,125,125
Data 132,126,125,132,125,124,132,126,124,130,128,124,131,130,124,128,130,125,125,132,125,124,132,127,124,129,130,124,128,133,125,125,133,128,124,130,130,125,125,133,126,124,129,130,124,126,132,126,123,130,131,124,125,133,129,124,127,132,126,124,130,130,125,125
Data 133,128,124,125,134,127,124,126,134,126,124,126,133,125,124,127,134,125,124,126,133,125,124,126,134,126,123,125,133,127,123,125,131,130,123,124,129,133,124,123,126,134,127,123,125,131,131,125,124,127,134,129,123,125,130,134,125,123,126,133,132,124,124,128
Data 133,130,123,125,127,134,128,123,124,128,134,128,123,124,127,134,132,123,124,128,130,134,125,123,126,129,135,127,122,123,127,131,134,124,122,126,129,132,131,123,124,126,129,135,128,123,124,127,129,133,131,123,124,126,129,132,132,125,122,126,128,129,134,128
Data 122,123,127,129,131,134,126,121,125,127,129,130,134,124,121,124,127,129,129,133,129,121,122,126,129,129,129,134,127,121,123,127,129,129,129,133,128,121,122,126,128,129,129,130,133,124,121,123,127,129,129,129,129,133,126,122,123,127,129,129,129,129,130,132
Data 128,121,123,126,129,129,129,129,129,130,133,128,121,123,127,128,129,128,128,128,128,128,132,129,121,122,126,129,129,129,129,129,128,128,128,129,132,128,121,122,125,129,130,130,129,129,128,128,128,128,127,128,129,131,126,120,121,126,129,132,130,128,128,128
Data 128,127,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,127,127,128,127,128,127,128,127,127,128,128,127,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,128,128,127,128,128,127,128
Data 127,129,127,128,127,128,128,127,127,127,127,126,129,126,126,130,127,125,129,128,124,130,130,126,128,131,127,126,131,127,125,129,129,124,126,131,126,125,129,130,124,129,131,126,125,130,130,124,126,131,128,125,128,131,125,124,130,129,125,125,131,129,125,126
Data 130,129,124,125,131,128,124,126,131,129,124,126,131,129,124,124,131,130,125,124,128,132,126,123,127,131,128,124,125,131,130,125,124,127,133,128,124,125,130,132,128,123,126,131,132,126,123,128,131,131,125,124,126,132,131,125,124,126,132,132,127,124,126,131
Data 133,129,124,124,126,132,130,124,123,125,130,133,128,124,123,127,132,133,128,123,124,127,131,133,128,124,124,127,131,133,130,124,123,125,129,132,132,128,123,124,128,130,132,131,125,122,124,128,131,133,131,125,121,124,126,130,132,131,128,122,122,126,128,130
Data 133,131,127,122,123,127,129,131,132,131,128,122,121,126,128,130,132,132,131,126,122,122,126,128,130,131,132,132,127,122,121,123,127,130,130,131,132,131,126,123,121,123,127,129,130,130,131,132,130,126,121,120,122,127,130,131,130,130,131,131,130,126,122,120
Data 121,126,129,131,131,130,130,130,130,129,127,124,121,120,123,127,129,131,131,131,130,129,130,130,130,128,127,123,122,121,122,126,128,131,132,131,131,130,129,129,129,129,129,128,127,127,122,119,123,128,128,129,129,128,129,128,127,128,127,128,128,127,128,126
Data 127,127,127,128,127,128,127,127,128,126,128,127,127,128,127,128,127,127,128,127,128,127,128,127,127,128,127,128,127,127,127,127,128,126,128,126,128,128,128,128,127,128,127,128,126,128,126,128,128,127,128,127,128,126,128,126,128,127,127,127,127,128,127,128
Data 127,128,126,128,126,128,127,129,127,128,127,128,127,128,128,128,127,128,128,128,127,128,128,128,127,127,127,127,127,127,128,127,127,128,128,127,127,128,127,128,127,128,127,128,127,129,127,128,127,129,127,128,127,128,127,127,128,127,128,127,129,127,128,127
Data 128,127,128,127,127,128,127,128,126,128,127,128,128,127,128,127,129,127,128,127,127,128,127,128,127,128,127,128,128,127,128,126,128,127,128,127,126,129,127,129,128,127,128,127,129,127,128,128,127,129,127,128,127,127,129,127,129,128,127,129,127,128,128,127
Data 128,127,127,128,126,128,127,127,128,127,128,128,127,129,127,127,128,127,128,128,127,129,127,127,128,127,127,128,127,129,128,127,129,127,127,129,127,128,129,127,128,128,127,128,128,126,128,128,126,129,128,126,129,127,126,129,128,127,129,128,127,129,127,126
Data 128,127,126,128,128,126,128,128,127,128,128,127,127,129,127,127,129,127,127,128,128,127,128,128,127,127,128,127,127,129,127,127,128,128,127,128,129,127,127,129,128,127,128,129,127,126,128,127,126,127,129,127,126,128,128,127,127,129,128,127,127,129,127,127
Data 128,129,127,127,128,128,127,127,128,128,127,127,129,128,127,127,129,128,127,127,129,128,127,127,129,128,127,127,128,129,127,127,128,129,127,127,127,129,128,127,127,128,128,127,127,127,129,127,127,127,128,128,127,127,127,129,127,127,127,128,129,127,127,127
Data 128,128,127,127,127,129,129,127,127,127,128,128,127,127,127,128,129,127,127,127,128,129,128,127,127,128,129,128,127,127,127,128,129,127,127,127,127,128,128,127,127,127,128,128,128,127,127,127,128,128,128,127,127,127,128,128,129,127,127,127,127,128,128,128
Data 127,127,127,128,128,128,128,127,127,127,128,128,128,128,127,127,127,128,128,128,128,127,127,127,127,128,128,128,128,127,127,127,128,128,128,128,128,127,127,127,127,128,128,128,128,128,127,127,127,128,128,128,128,128,128,127,127,127,128,128,128,128,128,128
Data 128,127,127,127,128,128,128,128,128,128,128,128,127,127,127,128,128,128,128,128,128,128,128,128,127,127,127,127,128,128,128,128,128,128,128,128,128,128,127,127,127,128,128,128,128,128,128,128,128,128,127,128,128,128,128,127,127,127,128,128,128,128,128,127
Data 128,127,128,128,128,128,128,128,128,0

.makeSound
	Restore shoot
	Read ln
	pos=0

	Repeat
		fileName$="C:\sound"+Rnd(1,1000)+".wav"
	Until FileType(fileName)=0

	fileOut=WriteFile(fileName)
		For pos=0 To ln-1
			Read bt
			WriteByte fileOut,bt
		Next
	CloseFile fileOut

	Global shootSound=LoadSound(fileName)
	DeleteFile fileName
Return


Yay! I support you 518.9014%!

Community projects are really motivating! Keep it up!

I love the flashing screen when you get hurt!
I hope this helps some newer coders.

WHOA!!!

Really really fast!

I also like the idea that it has no media - it would be really cool if you released a really neat game that needed no media. The game download would only be half a meg!

Thats one fast game!
Verry good, and nice code too.

I added some space ships I coded a while back.

Type Control_Type
	Field Max_Bombs
	Field Bomb_Speed
	Field Crit_Drop_Speed
	Field drop_bomb_chance
	Field Player_Speed
	Field Bullet_Speed
	Field Max_Rows
	Field Max_Cols
	Field XRes, YRes, Depth
	Field Beast_Speed#
	Field Beast_Speed_Increment#
	Field UFO_Speed
End Type

Type points_type
	Field x,y
	Field id
End Type

Type explosion_type
	Field x,y
	Field speed
	Field status
	Field dirx,diry
	Field count
	Field id
End Type

Type Player_Type
	Field x,y
	Field moved
End Type

Type stars_type
	Field image
	Field x,y
	Field count
End Type

Type Beast_Type
Field x#,y#
Field deleted
End Type

Type Bullet_Type
	Field fired
	Field x,y
End Type

Type Bomb_Type
	Field fired
	Field x,y
	Field deleted 
End Type

Type UFO_Type
	Field x,y
	Field status
End Type

;*********************************
; Create and Set up Control Type
; This is used to manage all our game control variables,
; it's easier keeping them in one place and putting the set up at the start means we can 
; control the details in the rest of the set up from here on in

Global control.Control_Type
Set_Up_Control

; Set graphics size
Graphics control\xres,control\yres,control\depth
AutoMidHandle True

Dim im(15)
Dim bases(3)
Dim Points_Ims(16)
Dim debri(16)
Dim stars.stars_type(3)

Global bim 
Global ufo_im
Global ship_im 
Global bomb_im = CreateImage(2,32)
Global xp,yp
Global blank_im = CreateImage(6,24)
Global point.points_Type
Global bullet_im = CreateImage(2,16)
Global dir# = control\beast_speed
Global score = 0
Global beast_count, total_beasts
Global x#, y#

Global explosion.Explosion_type
Global player.Player_Type
Global beast.Beast_Type
Global bullet.bullet_type
Global bombs.bomb_type
Global ufo.ufo_type = New ufo_type

Make_Collision_Image
Make_Player_Image
Make_Beast_Images
Make_Beasts
Make_Bases
Make_Points_Ims
Make_Blank
Make_Bombs
Make_Bullets
Make_Debri
Make_Stars
Make_Ship
Make_Ufo
Make_Player
Make_Bullet

SetBuffer BackBuffer()

While Not(KeyDown(1))
	time# = MilliSecs()

	Move_stars	
	af = (af + 1) And 15
	
	min_x = control\xres
	max_x = 0

	new_ufo
	If ufo\status = True Then move_ufo

	bomb_count = 0
	For bombs = Each bomb_type
		bomb_count = bomb_count + 1
		DrawImage bomb_im,bombs\x,bombs\y
		bombs\y = bombs\y + control\bomb_speed
		
		If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(0),192,400,0) Then
			SetBuffer ImageBuffer(bases(0))
			Color 0,0,0
			bxp = bombs\x - 168
			byp = bombs\y -368
			draw_blank bxp,byp
			SetBuffer BackBuffer()
			Delete bombs
			bomb_count = bomb_count-1
		Else
			If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(1),320,400,0) Then
				SetBuffer ImageBuffer(bases(1))
				Color 0,0,0
				bxp = bombs\x - 288
				byp = bombs\y -368
				draw_blank bxp,byp	
				SetBuffer BackBuffer()
				Delete bombs
				bomb_count = bomb_count-1
			Else
				If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(2),448,400,0) Then
					SetBuffer ImageBuffer(bases(2))
					Color 0,0,0
					bxp = bombs\x - 420
					byp = bombs\y -368
					draw_blank bxp,byp
					SetBuffer BackBuffer()
					Delete bombs
					bomb_count = bomb_count-1
				Else	
					If ImagesCollide(bomb_im,bombs\x,bombs\y,0,ship_im,player\x,player\y,0) Then
						bomb_count=bomb_count-1
						Delete bombs
						For i = 0 To 10
							ClsColor Rnd(255),Rnd(255),Rnd(255)
							Cls
							Flip
						Next
					Else
						If bombs\y > 480 Then Delete bombs : bomb_count=bomb_count-1
					EndIf
				EndIf
			EndIf
		EndIf
	Next

	
	check_bullets_and_bases

	player\moved = False

	bomb_dropped = False
	
	

	beast_hit = False

	For beast = Each beast_Type
		dokeys
		If beast\deleted = False Then
			x = beast\x + dir : y = beast\y
			If inc_y = True Then y = y + control\crit_drop_speed
			If dir > 0 Then
				If x > max_x Then max_x = x
			Else
				If x < min_x Then min_x = x
			EndIf
			
			beast\x = x
			beast\y = y

			DrawImage im(af),beast\x, beast\y
	
			If bullet\fired = True Then
				If ImagesCollide(im(af),beast\x,beast\y,0,bim,bullet\x,bullet\y,0) Then

					Add_Point beast\x , beast\y
					score = score + 10
					
					beast_count = beast_count-1 : beast_hit = True
					
					Make_Explosion beast\x,beast\y,5
					
									
					beast\deleted = True
					bullet\fired = False
				EndIf
			EndIf
			
			If bomb_dropped = False Then
				If bomb_count < control\max_bombs Then
					If Rand(100)<control\drop_bomb_chance Then
						bomb_count = bomb_count+1
						bomb_dropped = True
						bombs = New bomb_type
						bombs\x = beast\x : bombs\y = beast\y
					EndIf
				EndIf
			EndIf
			
		EndIf
	Next
	
	If beast_hit = True Then Increase_Beast_Speed
  
	inc_y = False
	If dir >0 Then
		If max_x > 608 Then dir = -dir : inc_y = True
	Else
		If min_x < 32 Then dir = - dir : inc_y = True
	EndIf


	Do_Points	
	DoExplosion
	Check_Bullets_And_Ufo
	Move_And_Draw_Bullet
	
	DrawImage ship_im,player\x,player\y

	DrawImage bases(0),192,400
	DrawImage bases(1),320,400
	DrawImage bases(2),448,400
	
	Color 255,255,255
	
;	Text 0,0,MilliSecs()-time
;	Text 0,16,dir
	Text control\xres - (Len(Str(score))*16),0,score
;	Text 0,32,beast_hit
	Flip
Wend

End

Function Set_Up_Control()
control.Control_Type = New Control_Type
control\max_bombs = 5
control\bomb_speed = 8
control\crit_drop_Speed = 8
control\drop_bomb_chance = 5
control\player_speed = 4
control\bullet_speed = 24
control\max_rows = 7
control\max_cols = 11
control\xres = 640 ; Try this pair at different resolution: 640,480 or 1024,768 or 1280,1024
control\yres = 480; 
control\depth = 16;
control\Beast_Speed = 1
control\Beast_Speed_Increment = 0.05
control\UFO_Speed = 2

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
	If bullet\fired = False Then
		bullet\x = player\x : bullet\y = 460
		bullet\fired = True
	EndIf
EndIf

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

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(2))-1
			explosion\diry = Int(Rand(2))-1
			explosion\status = 1
			explosion\count = 10
		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
End Function

Function Check_Bullets_And_UFO()
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
			score = score + 50
		EndIf
	EndIf
EndIf
End Function

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

Function Check_Bullets_And_Bases()
	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
				bullet\fired = False
				SetBuffer ImageBuffer(bases(i))
				xp = bullet\x - (160 + (i * 128))
				yp = bullet\y - 384
				draw_Blank xp,yp
				SetBuffer BackBuffer()
			EndIf
			If bullet\fired = False Then Exit
		Next

		If bullet\y < 0 Then 
			bullet\fired = False
		EndIf
	EndIf
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()

	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,2,2,True
Next

End Function

Function New_Ufo()

If ufo\status = False Then
	If Rand(100) < 10 Then
		ufo\status = True
		ufo\x = 640
	EndIf
EndIf

End Function

Function Move_Ufo()
	ufo\x = ufo\x - control\ufo_speed
	If ufo\x < 0 Then
		ufo\status = False
	EndIf
	DrawImage ufo_im,ufo\x,ufo\y+30
End Function

Function Make_Ufo()
	ufo_im = CreateImage(100,100)
	;Color 0,255,0
	SetBuffer ImageBuffer(ufo_im)
	;rockets
For i = 1 To 3
	Color 75-(10*i),75,75-(10*i)
	Line 25+i,60,25+i,95-(i*5) ;left rocket
	Line 25-i,60,25-i,95-(i*5)
	Line 75+i,60,75+i,95-(i*5) ;right rocket
	Line 75-i,60,75-i,95-(i*5)
Next
Line 25,60,25,70
Line 75,60,75,70
Color 175,75,75
Line 25,65,25,95
Line 75,65,75,95
;mid section
For i = 1 To 4 ;neck
 	Color 40,80,40
	Line 50+i,20+(i*7),50+i,100-(i*7) 
	Line 50-i,20+(i*7),50-i,100-(i*7)
Next 
For i = 1 To 4 ;neck highlight
	Color 70,100,70
	Line 50+i,20+(i*7),50+i,90-(i*7) 
	Line 50-i,20+(i*7),50-i,90-(i*7)
Next 
For i = 1 To 3
	Line 50+i,0+(i*10),50+i,60 
	Line 50-i,0+(i*10),50-i,60
Next
 
;wings
For i = 1 To 25
	Color 55+i,75+(i*2),25+i
	Line 50-i,40+i,50-i,60+i
	Line 50+i,40+i,50+i,60+i
Next 
;wing tips
Line 75,65,75,84
Line 25,65,25,84
For i = 1 To 25
	;Color 125-i,150-i,125-i
	Color 80-i,130-(i*3),50-i
	Line 75+i,65-i,75+i,85-Ceil(i*1.75)
	Line 25-i,65-i,25-i,85-Ceil(i*1.75)
Next 
;head
Color 30,80,30
For i = 1 To 10
	Line 50+Ceil(i/2),100-i,50-Ceil(i/2),100-i ;forhead
Next 
For i = 1 To 5
	Line 45+i,90-i,55-i,90-i 
Next
Color 25,25,25
For i = 1 To 5
	Line 50+Ceil(i/2),97-i,50-Ceil(i/2),97-i ;forhead
Next 
Color 175,75,75
Line 50,0,50,10 
;center body and rocket centers
Color 50,70,20
Line 50,38,50,63 ;wings center line
Color 70,90,70
Line 50,10,50,86
For i = 1 To 75 Step 6
Color 175-i,75-i,75-i
Plot 50,0+i
Next 
Color 70,90,70
Line 51,56,75,80
Line 49,56,25,80
Line 90,55,75,80
Line 10,55,25,80

ScaleImage ufo_im,.75,.75
RotateImage ufo_im,90	
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 = CreateImage(16,16)
SetBuffer ImageBuffer(bim)
ClsColor 0,0,0
Cls
Color 255,255,255
Oval 8,8,8,8,True
SetBuffer BackBuffer()
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_Bases()
For i = 0 To 3
	bases(i) = CreateImage(64,32)
	MaskImage bases(i),255,0,255
	SetBuffer ImageBuffer(bases(i))
	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
Next	
End Function

Function Make_Bombs()
SetBuffer ImageBuffer(bomb_im)
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_Bullets()
SetBuffer ImageBuffer(bullet_im)
Color 0,255,255
For i = 0 To 15
	If i And 1 Then Plot 0,i Else Plot 1,i
Next 
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.Player_Type = New Player_Type	; create player
player\x = 320 : player\y = 460			; position player on screen
End Function

Function Make_Beasts()
; this produces a grid of beasts and puts them into their correct positions on screen
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 + 32.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 Make_Bullet()
; This creates the players bullet used throughout the whole game
	bullet = New bullet_type	; create bullet
	bullet\fired = False		; set that it's not been fired
End Function

Function Increase_Beast_Speed()
Text 320,460,"+++"
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



Greetings Puppies,

Well sweet, thanks, though you might want to reduce the size of the mothership ;0).

Peace,

Jes

Man - it's amazing what you can do with no media! Those actually look like bitmaps!

i think that its a great idea and have contributed a small no media arkanoid clone, i doubt it will be very usefull butt if anyone wants to use it be my guest.

i removed the code due to its impracticality, and that about half of it was missing. see below where i have posted the improved code sorry about the messs

Grindalf, please try not to take offence at this, however, I'm sure you will, so sorry... but that code is very very ugly and really should be used as an example of how not to do it. Although I've only skimmed your code:

You should never never have

.loop
stuff
goto loop

Bad Bad Bad

The amount of repeated code on you if p1hp>0 stuff should be a function.

Your multiple variable p1hp p2hp etc could be an array and you repeated if statements could be reduced to a loop and a single if statement.

I'm not going to go into it further, but it's full of very bad coding practice.

Again, sorry if I've caused offence.

thanks, maybe when i paste in my missing code tommorow you could redo it better and show me how its done. i've never been fully sure of how to use arays.

I couldn't run it - too many errors.

sorry about the mess up there i've deleted it now. i think this might be better i've looked into types, tell me what you think.

Graphics 1030,700,16,2
AppTitle "block blaster"
HidePointer



;================globals=================
Global points
Global sztim
Global ppx=0
Global ppy=0
Global npower=0
Global x2=550
Global lev=1
Global x=500
Global lives=3
Global y2=640
Global ysp=5
Global sz=100
Global move=0
Global xsp=0
SetBuffer BackBuffer()
cr=Rand(50,150)
cg=Rand(50,150)
cb=Rand(50,150)
ClsColor cr,cg,cb



;=======================pills==============
SeedRnd MilliSecs()
Type pill
Field px
Field py
Field r
Field g
Field b
Field hp
Field pillamount=36
End Type

For tmpy=150 To 300 Step 30
For tmpx=250 To 750 Step 100 
pills.pill=New pill
pills\px=tmpx
pills\py=tmpy
pills\r=Rand(100,200)
pills\g=Rand(100,200)
pills\b=Rand(100,200)
pills\hp=1
Next 
Next




;======================main loop=====================================
While KeyDown(1)=False
If move=0 Then x2=x+sz/2
graphicsdraw()
controls()
If move=1 Then ballmovement()
If lives=0 Then End
Flip
tothp=0
For pills.pill=Each pill
If pills\hp=0 Then tothp=tothp+1
Next 
If tothp=36 Then newlev()
Wend
End
;=======================keybord controls===========================
Function controls()
If KeyDown(203) And x>190 Then x=x-5
If KeyDown(205) And x<900-sz Then x=x+5
If KeyDown(57) Then move=1
End Function
;========================graphics==========================
Function graphicsdraw()
Cls
; level walls
Color 30,30,30
Rect 0,0,190,700
Rect 900,0,130,700
Rect 0,0,1030,50
Color 70,70,70
Rect 20,110,150,500
Rect 903,125,120,225
Color 0,0,0
Line 190,50,190,700
Line 190,50,900,50
Line 900,50,900,700
Rect 20,110,150,500,0
Rect 903,125,120,225,0
; player bat
Color 100,100,100:Rect x,650,sz,30:Color 50,0,0:Rect x,650,20,30:Rect x+sz-20,650,20,30:Color 0,0,0:Rect x,650,sz,30,0
If bat=2 Then Color 0,50,0:Rect x,650,sz,30:Color 0,0,50:Rect x,650,20,30:Rect x+sz-20,650,20,30:Color 0,0,0:Rect x,650,sz,30,0:Color 50,50,50:Rect x+45,640,15,30:Color 0,0,0:Rect x+45,640,15,30,0
; ball
Color 150,150,0:Oval x2,y2,10,10,1:Color 0,0,0:Oval x2,y2,10,10,0
; pills
pills.pill=First pill 
If pills\hp=1 Then Color pills\r,pills\g,pills\b:Rect pills\px,pills\py,100,30,1:Color 0,0,0:Rect pills\px,pills\py,100,30,0
For tmp=1 To 35
pills=After pills 
If pills\hp=1 Then Color pills\r,pills\g,pills\b:Rect pills\px,pills\py,100,30,1:Color 0,0,0:Rect pills\px,pills\py,100,30,0
Next
;power pill
ppr=Rand(0,255)
ppg=Rand(0,255)
ppb=Rand(0,255)
If npower>0 Then ppy=ppy+1
If npower>0 Then Color ppr,ppg,ppb:Rect ppx,ppy,60,30:Color 0,0,0:Rect ppx,ppy,60,30,0:Text ppx+10,ppy+5,"power"
If npower>0 And ppy>700 Then npower=0
If npower>0 And ppy+30>650 And ppy<y+680 And ppx<x+sz And ppx+60>x Then sz=150:sztim=1000:npower=0
sztim=sztim-1
If sztim<0 Then sz=100
; text lines
Color 0,0,0
Text 60,130,"pills "+points
Text 60,295,"level "+lev
Text 60,430,"lives"+lives
Text 930,130,"CONTROLS"
Text 905,170,"left and right"
Text 905,190,"to move bat."
Text 905,330,"Esc to exit"
Delay 1
End Function
;=======================ball movement and colisions================================
Function ballmovement()
y2=y2+ysp
x2=x2+xsp
If xsp>5 Then xsp=5
If xsp<-5 Then xsp=-5
Select True 
Case y2>650 And y2<680 And x2+10>x And x2<x+sz/2+1
ysp=-5
xsp=xsp-1
Case y2>650 And y2<680 And x2>x+sz/2 And x2<x+sz
ysp=-5
xsp=xsp+1
Case y2>700
lives=lives-1
x2=x+sz/2
y2=640
xsp=0
move=0
Case y2<50
ysp=5
Case x2>900
xsp=xsp-xsp*2
Case x2<190
xsp=xsp-xsp*2
End Select 

; ball to pill collision
pills.pill=First pill
If pills\hp=1 And x2+20>pills\px+2 And x2<pills\px+98 And y2+20>pills\py And y2<pills\py+30 Then ysp=ysp-ysp*2:pills\hp=0:power=Rand(-5,1)pwx=x2:pwy=y2:points=points+1
If pills\hp=1 And x2+10>pills\px And x2<pills\px+10 And y2-10>pills\py And y2<pills\py+30 Then xsp=xsp-xsp*2:pills\hp=0:power=Rand(-5,1)pwx=x2:pwy=y2:points=points+1
If pills\hp=1 And x2<pills\px+100 And x2>pills\px+90 And y2-10>pills\py And y2<pills\py+30 Then xsp=xsp-xsp*2:pills\hp=0:power=Rand(-5,1)pwx=x2:pwy=y2:points=points+1
For tmp=1 To 35
pills=After pills 
If pills\hp=1 And x2+10>pills\px And x2<pills\px+10 And y2-10>pills\py And y2<pills\py+30 Then xsp=xsp-xsp*2:pills\hp=0:power=Rand(-5,2):pwx=x2:pwy=y2:points=points+1
If pills\hp=1 And x2<pills\px+100 And x2>pills\px+90 And y2-10>pills\py And y2<pills\py+30 Then xsp=xsp-xsp*2:pills\hp=0:power=Rand(-5,2):pwx=x2:pwy=y2:points=points+1
If pills\hp=1 And x2>pills\px+2 And x2<pills\px+98 And y2+20>pills\py And y2<pills\py+30 Then ysp=ysp-ysp*2:pills\hp=0:power=Rand(-5,2):pwx=x2:pwy=y2:points=points+1
Next
If npower<1 Then npower=power:ppy=pwy:ppx=pwx

End Function

;=========================new level==============================
Function newlev()
For pills.pill=Each pill
pills\hp=1
pills\r=Rand(100,200)
pills\g=Rand(100,200)
pills\b=Rand(100,200)
Next
lev=lev+1
cr=Rand(50,150)
cg=Rand(50,150)
cb=Rand(50,150)
ClsColor cr,cg,cb
End Function



Greetings Puppies,

From a quick glance it looks better. I'll have a proper play next week after my exams are over.

Peace,

Jes

I really like that game!

It's addictive and fun!

The game it's self is ok. I like the power-up thing.

But if you want to improve it...
The code is very hard to read.
Part of the reason is the way you define variables.
Look at this line
( If npower<1 Then npower=power:ppy=pwy:ppx=pwx )

I can tell what npower is and power but ppy,pwy,ect...?
In short, use full words. Your variables should give some idea of what they do. If you get into big programs you will see the value of this.

Next, correct me if I'm wrong, but I can't find where you are deleting the pill types when hit.

I don't know if you had it indented before posting it here but in case you didn't, You should learn to indent your code. It makes is way easier to read.

In your collision test you have...
 If pills\hp=1 And x2+20>pills\px+2 And x2<pills\px+98 And y2+20>pills\py And y2<pills\py+30 Then ysp=ysp-ysp*2:pills\hp=0:power=Rand(-5,1)pwx=x2:pwy=y2:points=points+1


I think you should look at using images overlap
if imagesoverlap ball,pill then...


Well thats all I'll say for now. I'm just passing on advice others have given me.

but correct me if im wrong but imagesoverlap only works with loadimage(media), and i deliberetly made this without so the imageoverlap wouldent work would it.?

oh and sorry about it being confusing. i'll try and put more remarks and better named variables next time.

ImagesOverlap (image1,x1,y1,image2,x2,y2)

No where in there does it say that the image has to be loaded with LoadImage.

Instead of executing all of your drawing code every frame, you could have (should have) created some images using the CreateImage command and just drew to them one time. This would then allow you to use the ImagesOverlap or ImagesCollide commands.

Greetings Puppies,

Had a look at the game and it plays sweetly, but what Wolron says it right. If you look at the code for the space invaders above, especially the CreateImage() & 'SetBuffer ImageBuffer()' line, you'll see that you can create images in code that exhibit the same behaviour as loaded media.

As I said, I'll take a good look next week and open another topic with an updated version of this.

Peace,

Jes

thanks for the input, your comments have made made my programing easyer better and less space consuming(my original code for that game was 800+lines).

I have a little program that may teach beginners more things about 3D. It's a 3D program called SpinShooter - it's a real beginner program. I made it cause I was bored.

View here.

grindalf, you should try and tab you code, when it comes to functions or loops or if's. So, your code would become:

Graphics 1030,700,16,2
AppTitle "block blaster"
HidePointer



;================globals=================
Global points
Global sztim
Global ppx=0
Global ppy=0
Global npower=0
Global x2=550
Global lev=1
Global x=500
Global lives=3
Global y2=640
Global ysp=5
Global sz=100
Global move=0
Global xsp=0
SetBuffer BackBuffer()
cr=Rand(50,150)
cg=Rand(50,150)
cb=Rand(50,150)
ClsColor cr,cg,cb



;=======================pills==============
SeedRnd MilliSecs()

Type pill
	Field px
	Field py
	Field r
	Field g
	Field b
	Field hp
	Field pillamount=36
End Type

For tmpy=150 To 300 Step 30
	For tmpx=250 To 750 Step 100 
		pills.pill=New pill
		pills\px=tmpx
		pills\py=tmpy
		pills\r=Rand(100,200)
		pills\g=Rand(100,200)
		pills\b=Rand(100,200)
		pills\hp=1
	Next 
Next




;======================main loop=====================================
While KeyDown(1)=False
	If move=0 Then x2=x+sz/2

	graphicsdraw()
	controls()

	If move=1 Then ballmovement()
	If lives=0 Then End

	Flip

	tothp=0

	For pills.pill=Each pill
		If pills\hp=0 Then tothp=tothp+1
	Next 

	If tothp=36 Then newlev()

Wend
End
;=======================keybord controls===========================
Function controls()
	If KeyDown(203) And x>190 Then x=x-5
	If KeyDown(205) And x<900-sz Then x=x+5
	If KeyDown(57) Then move=1
End Function
;========================graphics==========================
Function graphicsdraw()
	Cls
	
	; level walls
	Color 30,30,30
	Rect 0,0,190,700
	Rect 900,0,130,700
	Rect 0,0,1030,50
	Color 70,70,70
	Rect 20,110,150,500
	Rect 903,125,120,225
	Color 0,0,0
	Line 190,50,190,700
	Line 190,50,900,50
	Line 900,50,900,700
	Rect 20,110,150,500,0
	Rect 903,125,120,225,0
	
	; player bat
	Color 100,100,100:Rect x,650,sz,30:Color 50,0,0:Rect x,650,20,30:Rect x+sz-20,650,20,30:Color 0,0,0:Rect x,650,sz,30,0
	If bat=2 Then Color 0,50,0:Rect x,650,sz,30:Color 0,0,50:Rect x,650,20,30:Rect x+sz-20,650,20,30:Color 0,0,0:Rect x,650,sz,30,0:Color 50,50,50:Rect x+45,640,15,30:Color 0,0,0:Rect x+45,640,15,30,0
	
	; ball
	Color 150,150,0:Oval x2,y2,10,10,1:Color 0,0,0:Oval x2,y2,10,10,0
	
	; pills
	pills.pill=First pill 
	If pills\hp=1 Then Color pills\r,pills\g,pills\b:Rect pills\px,pills\py,100,30,1:Color 0,0,0:Rect pills\px,pills\py,100,30,0
	For tmp=1 To 35
	pills=After pills 
	If pills\hp=1 Then Color pills\r,pills\g,pills\b:Rect pills\px,pills\py,100,30,1:Color 0,0,0:Rect pills\px,pills\py,100,30,0
	Next
	
	;power pill
	ppr=Rand(0,255)
	ppg=Rand(0,255)
	ppb=Rand(0,255)
	If npower>0 Then ppy=ppy+1
	If npower>0 Then Color ppr,ppg,ppb:Rect ppx,ppy,60,30:Color 0,0,0:Rect ppx,ppy,60,30,0:Text ppx+10,ppy+5,"power"
	If npower>0 And ppy>700 Then npower=0
	If npower>0 And ppy+30>650 And ppy<y+680 And ppx<x+sz And ppx+60>x Then sz=150:sztim=1000:npower=0
	sztim=sztim-1
	If sztim<0 Then sz=100
	
	; text lines
	Color 0,0,0
	Text 60,130,"pills "+points
	Text 60,295,"level "+lev
	Text 60,430,"lives"+lives
	Text 930,130,"CONTROLS"
	Text 905,170,"left and right"
	Text 905,190,"to move bat."
	Text 905,330,"Esc to exit"
	Delay 1
End Function
;=======================ball movement and colisions================================
Function ballmovement()

	y2=y2+ysp
	x2=x2+xsp
	If xsp>5 Then xsp=5
	If xsp<-5 Then xsp=-5
	Select True 
		Case y2>650 And y2<680 And x2+10>x And x2<x+sz/2+1
			ysp=-5
			xsp=xsp-1
		Case y2>650 And y2<680 And x2>x+sz/2 And x2<x+sz
			ysp=-5
			xsp=xsp+1
		Case y2>700
			lives=lives-1
			x2=x+sz/2
			y2=640
			xsp=0
			move=0
		Case y2<50
			ysp=5
		Case x2>900
			xsp=xsp-xsp*2
		Case x2<190
			xsp=xsp-xsp*2
	End Select 
	
	; ball to pill collision
	pills.pill=First pill
	If pills\hp=1 And x2+20>pills\px+2 And x2<pills\px+98 And y2+20>pills\py And y2<pills\py+30 Then ysp=ysp-ysp*2:pills\hp=0:power=Rand(-5,1)pwx=x2:pwy=y2:points=points+1
	If pills\hp=1 And x2+10>pills\px And x2<pills\px+10 And y2-10>pills\py And y2<pills\py+30 Then xsp=xsp-xsp*2:pills\hp=0:power=Rand(-5,1)pwx=x2:pwy=y2:points=points+1
	If pills\hp=1 And x2<pills\px+100 And x2>pills\px+90 And y2-10>pills\py And y2<pills\py+30 Then xsp=xsp-xsp*2:pills\hp=0:power=Rand(-5,1)pwx=x2:pwy=y2:points=points+1

	For tmp=1 To 35
		pills=After pills 
		If pills\hp=1 And x2+10>pills\px And x2<pills\px+10 And y2-10>pills\py And y2<pills\py+30 Then xsp=xsp-xsp*2:pills\hp=0:power=Rand(-5,2):pwx=x2:pwy=y2:points=points+1
		If pills\hp=1 And x2<pills\px+100 And x2>pills\px+90 And y2-10>pills\py And y2<pills\py+30 Then xsp=xsp-xsp*2:pills\hp=0:power=Rand(-5,2):pwx=x2:pwy=y2:points=points+1
		If pills\hp=1 And x2>pills\px+2 And x2<pills\px+98 And y2+20>pills\py And y2<pills\py+30 Then ysp=ysp-ysp*2:pills\hp=0:power=Rand(-5,2):pwx=x2:pwy=y2:points=points+1
	Next
	If npower<1 Then npower=power:ppy=pwy:ppx=pwx

End Function

;=========================new level==============================
Function newlev()
	For pills.pill=Each pill
		pills\hp=1
		pills\r=Rand(100,200)
		pills\g=Rand(100,200)
		pills\b=Rand(100,200)
	Next
	lev=lev+1
	cr=Rand(50,150)
	cg=Rand(50,150)
	cb=Rand(50,150)
	ClsColor cr,cg,cb
End Function


Looks alot neater, and you can tell the beginning and end of loops, and if's and such. :o)

This community project isn't getting anywhere.

Greetings Puppies,

I finish my exams today so I'll be able to concentrate on it a little more.

Peace,

Jes

Greetings Puppies,

Here is some updated code. The program is 'complete', ie, it has multiple levels, lives, extra lives, scoring, a high score table, an intro screen, a level indicator, etc. All of the above work, though they're not necessarily the best way forward.

If anyone would like to contribute, please feel free.

Type Control_Type
	Field Max_Bombs
	Field Bomb_Speed
	Field Crit_Drop_Speed
	Field drop_bomb_chance
	Field Player_Speed
	Field Bullet_Speed
	Field Max_Rows
	Field Max_Cols
	Field XRes, YRes, Depth
	Field Beast_Speed#
	Field Beast_Speed_Increment#
	Field UFO_Speed
	Field Level
	Field NextExtraLife
End Type

Type points_type
	Field x,y
	Field id
End Type

Type explosion_type
	Field x,y
	Field speed
	Field status
	Field dirx,diry
	Field count
	Field id
End Type

Type HighScoreTable_Type
	Field score
	Field name$
End Type

Dim HighScores.HighScoreTable_type(10)
Global highscore.highscoretable_type
Dim SpaceyFont(40)

Type Player_Type
	Field x,y
	Field moved
	Field lives
	Field score
End Type

Type stars_type
	Field image
	Field x,y
	Field count
End Type

Type Beast_Type
Field x#,y#
Field deleted
End Type

Type Bullet_Type
	Field fired
	Field x,y
End Type

Type Bomb_Type
	Field fired
	Field x,y
	Field deleted 
End Type

Type UFO_Type
	Field x,y
	Field status
End Type

;*********************************
; Create and Set up Control Type
; This is used to manage all our game control variables,
; it's easier keeping them in one place and putting the set up at the start means we can 
; control the details in the rest of the set up from here on in

Global control.Control_Type
Set_Up_Control

; Set graphics size
Graphics control\xres,control\yres,control\depth
AutoMidHandle True

Dim im(15)
Dim bases(3)
Dim Points_Ims(16)
Dim debri(16)
Dim stars.stars_type(3)

Global bim 
Global ufo_im
Global ship_im 
Global bomb_im = CreateImage(2,32)
Global xp,yp
Global blank_im = CreateImage(6,24)
Global point.points_Type
Global bullet_im = CreateImage(2,16)
Global dir# = control\beast_speed
Global score = 0
Global beast_count, total_beasts
Global x#, y#
Global EndGame = False
Global char$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 @#~"

Global explosion.Explosion_type
Global player.Player_Type
Global beast.Beast_Type
Global bullet.bullet_type
Global bombs.bomb_type
Global ufo.ufo_type = New ufo_type

player.Player_Type = New Player_Type	; create player

Make_Collision_Image
Make_Player_Image
Make_Beast_Images
Make_Beasts
Make_Bases
Make_Points_Ims
Make_Blank
Make_Bombs
Make_Bullets
Make_Debri
Make_Stars
Make_Ship
Make_Ufo
Make_Player
Make_Bullet
Make_HighScoreTable
Make_SpaceyFont

SetBuffer BackBuffer()

quit = displaystartscreen()

While quit = False

	endgame = False
	
	old_level = 0 : control\level = 1 : control\nextextralife = 2500
	make_player	
	While endgame = False

		If old_level <> control\level Then
			Introduce_Level
			StartNewLevel
			old_level = control\level
		End If
		
		If player\lives<=0 Then endgame =True 
		
		time# = MilliSecs()
		
		If player\score > control\nextextralife Then
			control\nextextralife = control\nextextralife + 2500
			player\lives = player\lives + 1
		End If

		Move_stars	
		Display_Info
		af = (af + 1) And 15
	
		min_x = control\xres
		max_x = 0

		new_ufo
		If ufo\status = True Then move_ufo

		bomb_count = 0
		For bombs = Each bomb_type
			bomb_count = bomb_count + 1
			DrawImage bomb_im,bombs\x,bombs\y
			bombs\y = bombs\y + control\bomb_speed
		
			If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(0),192,400,0) Then
				SetBuffer ImageBuffer(bases(0))
				Color 0,0,0
				bxp = bombs\x - 168
				byp = bombs\y -368
				draw_blank bxp,byp
				SetBuffer BackBuffer()
				Delete bombs
				bomb_count = bomb_count-1
			Else
				If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(1),320,400,0) Then
					SetBuffer ImageBuffer(bases(1))
					Color 0,0,0
					bxp = bombs\x - 288
					byp = bombs\y -368
					draw_blank bxp,byp	
					SetBuffer BackBuffer()
					Delete bombs
					bomb_count = bomb_count-1
				Else
					If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(2),448,400,0) Then
						SetBuffer ImageBuffer(bases(2))
						Color 0,0,0
						bxp = bombs\x - 420
						byp = bombs\y -368
						draw_blank bxp,byp
						SetBuffer BackBuffer()
						Delete bombs
						bomb_count = bomb_count-1
					Else	
						If ImagesCollide(bomb_im,bombs\x,bombs\y,0,ship_im,player\x,player\y,0) Then
							bomb_count=bomb_count-1
							Player\lives = player\lives-1
							Delete bombs
							For i = 0 To 10
								ClsColor Rnd(255),Rnd(255),Rnd(255)
								Cls
								Flip
							Next
						Else
							If bombs\y > 480 Then Delete bombs : bomb_count=bomb_count-1
						EndIf
					EndIf
				EndIf
			EndIf
		Next

	
		check_bullets_and_bases
	
		player\moved = False

		bomb_dropped = False
	
		beast_hit = False

		dokeys

		beast_count = 0
		For beast = Each beast_Type
			If beast\deleted = False Then
				beast_count = beast_count + 1
				x = beast\x + dir : y = beast\y
				If inc_y = True Then y = y + control\crit_drop_speed
				If dir > 0 Then
					If x > max_x Then max_x = x
				Else
					If x < min_x Then min_x = x
				EndIf
				
				If ImagesCollide(im(af), beast\x,beast\y,0,bases(0),192,400,0) = True Then 
					FreeImage bases(0) : bases(0) = CreateImage(1,1)
				Else If ImagesCollide(im(af), beast\x,beast\y,0,bases(1),320,400,0) = True Then
					 FreeImage bases(1) : bases(1) = CreateImage(1,1)
				Else If ImagesCollide(im(af), beast\x,beast\y,0,bases(2),448,400,0) = True Then
					FreeImage bases(2) : bases(2) = CreateImage(1,1)
				End If				
				beast\x = x
				beast\y = y

				DrawImage im(af),beast\x, beast\y
	
				If bullet\fired = True Then
					If ImagesCollide(im(af),beast\x,beast\y,0,bim,bullet\x,bullet\y,0) Then

						Add_Point beast\x , beast\y
						player\score = player\score + 10
					
						beast_count = beast_count-1 : beast_hit = True
					
						Make_Explosion beast\x,beast\y,5	
									
						beast\deleted = True
						bullet\fired = False
					EndIf
				EndIf
			
				If bomb_dropped = False Then
					If bomb_count < control\max_bombs Then
						If Rand(100)<control\drop_bomb_chance Then
							bomb_count = bomb_count+1
							bomb_dropped = True
							bombs = New bomb_type
							bombs\x = beast\x : bombs\y = beast\y
						EndIf
					EndIf
				EndIf
				
			EndIf
			
			If beast\y > 460 Then endgame = True
		Next
	
		If beast_hit = True Then Increase_Beast_Speed
  
		inc_y = False
		If dir >0 Then
			If max_x > 608 Then dir = -dir : inc_y = True
		Else
			If min_x < 32 Then dir = - dir : inc_y = True
		EndIf

		Do_Points	
		DoExplosion
		If ufo\status = True Then Check_Bullets_And_Ufo
		Move_And_Draw_Bullet
	
		If beast_count = 0 And ufo\status = False Then control\level = control\level + 1
		
		DrawImage ship_im,player\x,player\y

		DrawImage bases(0),192,400
		DrawImage bases(1),320,400
		DrawImage bases(2),448,400
	
		Color 255,255,255
	
		Flip
	Wend
	
	DisplayEndScreen
	EnterHighScore
	endgame = False
		
	Delay(500)
	FlushKeys
	
	quit = displaystartscreen()	
Wend
End

Function Set_Up_Control()
control.Control_Type = New Control_Type
control\max_bombs = 4
control\bomb_speed = 4
control\crit_drop_Speed = 4
control\drop_bomb_chance = 5
control\player_speed = 4
control\bullet_speed = 24
control\max_rows = 7
control\max_cols = 11
control\xres = 640 ; Try this pair at different resolution: 640,480 or 1024,768 or 1280,1024
control\yres = 480; 
control\depth = 16;
control\level = 1
control\Beast_Speed = 1
control\Beast_Speed_Increment = 0.05
control\UFO_Speed = 4
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
	If bullet\fired = False Then
		bullet\x = player\x : bullet\y = 460
		bullet\fired = True
	EndIf
EndIf

If player\moved = False Then
	If KeyDown(205) Then
		If player\x < 608 Then player\x = player\x + control\player_speed : player\moved = True
	EndIf
		
	If KeyDown(203) 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(2))-1
			explosion\diry = Int(Rand(2))-1
			explosion\status = 1
			explosion\count = 10
		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
End Function

Function Check_Bullets_And_UFO()
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
		EndIf
	EndIf
EndIf
End Function

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

Function Check_Bullets_And_Bases()
	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
				bullet\fired = False
				SetBuffer ImageBuffer(bases(i))
				xp = bullet\x - (160 + (i * 128))
				yp = bullet\y - 384
				draw_Blank xp,yp
				SetBuffer BackBuffer()
			EndIf
			If bullet\fired = False Then Exit
		Next

		If bullet\y < 0 Then 
			bullet\fired = False
		EndIf
	EndIf
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()

	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
	If Rand(100) < 10 Then
		ufo\status = True
		ufo\x = 640
		ufo\y = 32
	EndIf
EndIf

End Function

Function Move_Ufo()
	ufo\x = ufo\x - control\ufo_speed
	If ufo\x < 0 Then
		ufo\status = False
	EndIf
	DrawImage ufo_im,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 = CreateImage(16,16)
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 Make_Bullet()
; This creates the players bullet used throughout the whole game
	bullet = New bullet_type	; create bullet
	bullet\fired = False		; set that it's not been fired
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
	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
		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)
		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()
	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
	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_Bases()
For i = 0 To 3
	bases(i) = CreateImage(64,32)
	MaskImage bases(i),255,0,255
	SetBuffer ImageBuffer(bases(i))
	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
Next	
End Function

Function Make_Bombs()
SetBuffer ImageBuffer(bomb_im)
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_Bullets()
SetBuffer ImageBuffer(bullet_im)
Color 0,255,255
For i = 0 To 15
	If i And 1 Then Plot 0,i Else Plot 1,i
Next 
End Function

Function Make_Ufo()
	ufo_im = CreateImage(100,100)
	;Color 0,255,0
	SetBuffer ImageBuffer(ufo_im)
	;rockets
For i = 1 To 3
	Color 75-(10*i),75,75-(10*i)
	Line 25+i,60,25+i,95-(i*5) ;left rocket
	Line 25-i,60,25-i,95-(i*5)
	Line 75+i,60,75+i,95-(i*5) ;right rocket
	Line 75-i,60,75-i,95-(i*5)
Next
Line 25,60,25,70
Line 75,60,75,70
Color 175,75,75
Line 25,65,25,95
Line 75,65,75,95
;mid section
For i = 1 To 4 ;neck
 	Color 40,80,40
	Line 50+i,20+(i*7),50+i,100-(i*7) 
	Line 50-i,20+(i*7),50-i,100-(i*7)
Next 
For i = 1 To 4 ;neck highlight
	Color 70,100,70
	Line 50+i,20+(i*7),50+i,90-(i*7) 
	Line 50-i,20+(i*7),50-i,90-(i*7)
Next 
For i = 1 To 3
	Line 50+i,0+(i*10),50+i,60 
	Line 50-i,0+(i*10),50-i,60
Next
 
;wings
For i = 1 To 25
	Color 55+i,75+(i*2),25+i
	Line 50-i,40+i,50-i,60+i
	Line 50+i,40+i,50+i,60+i
Next 
;wing tips
Line 75,65,75,84
Line 25,65,25,84
For i = 1 To 25
	;Color 125-i,150-i,125-i
	Color 80-i,130-(i*3),50-i
	Line 75+i,65-i,75+i,85-Ceil(i*1.75)
	Line 25-i,65-i,25-i,85-Ceil(i*1.75)
Next 
;head
Color 30,80,30
For i = 1 To 10
	Line 50+Ceil(i/2),100-i,50-Ceil(i/2),100-i ;forhead
Next 
For i = 1 To 5
	Line 45+i,90-i,55-i,90-i 
Next
Color 25,25,25
For i = 1 To 5
	Line 50+Ceil(i/2),97-i,50-Ceil(i/2),97-i ;forhead
Next 
Color 175,75,75
Line 50,0,50,10 
;center body and rocket centers
Color 50,70,20
Line 50,38,50,63 ;wings center line
Color 70,90,70
Line 50,10,50,86
For i = 1 To 75 Step 6
Color 175-i,75-i,75-i
Plot 50,0+i
Next 
Color 70,90,70
Line 51,56,75,80
Line 49,56,25,80
Line 90,55,75,80
Line 10,55,25,80

ScaleImage ufo_im,.5,.25
RotateImage ufo_im,90	
End Function

Function SpaceyText(x,y,message$,centre)
If Len(message)>0 Then
	If centre = True Then
		length = Len(message) * ImageWidth(spaceyfont(0))
		xs = (640-length)/2
	Else
		xs = x
	End If
	
	For c = 1 To Len(message)
		v = 0
		ch$ = Mid$(Upper(message), c, 1)
		If ch>="0" And ch<="9" Then 
			v = 26 + Asc(ch)-48
		Else If ch>="A" And ch<="Z" Then 
			v = Asc(ch)-65
		Else
			v = 36
		End If
		
		DrawImage spaceyfont(v),xs + (c * ImageWidth(spaceyfont(0))), y
	Next			
End If
End Function


Peace,

Jes

This game is looking good. I might have some things to contribute.

No Enemies: No point saying the project isn't getting anywhere. If you concerned, you can contribute to it.

I made a contribution.

And I think we should also start teaching them 3D games, such as my simple SpinShooter. Because 3D is what most people are interested in.

Greetings Puppies,

If people want to contribute to this * 2d Space Invaders * project, then great. If you want to start threads of your own about 3d then that is also great. If most people want to do 3d, then that is great.

If you're not going to add code or contributive criticism, please can you not post here.

@RiverRatt: As you can see my presentation skills aren't particularly good (but that wasn't really the point). You've obviously got an artistic eye and if you want to improve any of the eye-candy, then that would be most welcome.

Peace,

Jes

No Enemies: Good idea! Your code for SpinShooter would be a good beginner 3d spinoff because most of the "beginner" codes floating around are mostly some FPS code.
And a good game is more about the basic idea.

/Alienforce

PS. PacMan is a game idea i like :)

I know that was not the point. The point is to make a game that is

"1) That people can see how certain things are done(eg, there are very basic particle and parallax effects);
2) That the Blitz Community can develop it into a complete game, ie, give it intro screens, player lives, level, etc, so that others can use it to learn how to make a complete game;
3) Finally, that reusable community code is developed so that people don't have to reinvent the wheel every time they want a high-score table, etc."

My interest here is in number 3. We can then show that by making reusible code that the same code can be used in 2d or 3d. And when this (2d) prodject is complete I will prove it.
As for the graphics I can supply a little editer I made for that, but that can wait till last don,t you think.

Greetings Puppies,

Of course, that'd be good. What else does this need (apart from commenting) - sound, I suppose is the obvious choice - but what else can we do with space invaders?

Peace,

Jes

First I think start rewriting the functions into self contained functions that don't need globals or any variables
asigned outside the functions. You know something like
badguy=get_image(badguy,badguy\x,badguy\y,badguy\height,badguy\width)


And for some general game Ideas...
The ufo at the top, when the ufo gets to certain point have iit turn and do a dive bomb at the player.

Or something a little easier, when the ufo is hit break it up into a bunch of little ships that dive at the player. That would be easy just replace some of the paricles whith scaled versions of the ufo and add collisions.

Another Idea is have some of the enemies break off and dive a the player then when it gets to the bottom of the screen it apears at the top and returns to its original position, like the original.

Something else might be powerups and extra lives that float down to the player.
Just some ideas...

Yay! We're sticky.

I'll contribute any code - I really want to - but just let me know what I need to do. I can't really think of anything - besides using external media...

Greetings Puppies,

@No Enemies : Have a go at RiverRatts second suggestion about turning the ufo particles into dive bombing aliens, that seems a good start, or possibly bonuses, eg, double shots?

Peace,

Jes

I have started working on an editor of sorts. So far its just a function, that might make it easier to add more ships. You just add a case to the select statment and specify the index number(along with width,height,and scale). It could be used to make all the images in one function.

Graphics 800,600
SetBuffer FrontBuffer()

player_ship=Make_image(player_ship,50,50,.75,.90,1)
player2=Make_image(player2,50,50,1.75,1.90,2)
player3=Make_image(player3,50,50,6,2,1)
player4=Make_image(player4,50,50,1,1,2)
player5=Make_image(player5,150,50,1,1,5)



SetBuffer BackBuffer()
While Not KeyHit(1)

Cls
Text 0,0,"A image function By RiverRatt"
DrawImage player_ship,MouseX(),MouseY()
DrawImage player2,100,100
DrawImage player3,MouseX(),100
DrawImage player4,500,MouseY()
DrawImage player5,400,300
DrawImage player_ship,MouseX(),MouseY()

Flip 
Wend
End

Function Make_image(image,width,height,scale_x#,scale_y#,index)
	
	
	image=CreateImage(width,height)
	SetBuffer ImageBuffer(image)
	MidHandle image
	Select (index)
		
			
		Case 1
			
			
			
			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 image,scale_x#,scale_y#
			
			Return image
		
		
		Case 2
			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
			ScaleImage image,scale_x#,scale_y#
			Return image
			
		Default
			image=CreateImage(255,50)
			SetBuffer ImageBuffer(image)
			MidHandle image

			Color 100,100,100
			Rect 0,0,255,50
			Color 1,1,1
			Text 0,20,"NO Index In Make_Image Function." 
			
			
			Return image 

		End Select 
		
End Function 






Next time I make a dll it will be in a game from scratch. Kind of a pain finding the globals I replaced. Anyhow here is an update of the space invaders. Not much different exept it will be a breeze making new ships and mixing different enimies and other graphics. Tell me what you think
please. It's my first dll, and replaces most of the drawing functions. There are a couple bugs I have to work out but nothing big.

The include with bug fixes
Dim im(15)
Dim bases(3)
Dim Points_Ims(16)
Dim debri(16)


;ingame setup________________________________________________________________________________________
;players ship
ship_im=Make_image(ship_im,50,50,.75,.75,1)
;enemy ships
For i=0 To 15
	im(i)=Make_image(im(i),50,50,.75,.75,2)
Next
;bases 
For i = 0 To 2
	bases(i)=Make_image(bases(i),64,32,1,1,3)
Next 
;collision image
bim=Make_image(bim,16,16,1,1,4)
;points
For i = 0 To 15
	Points_Ims(i)=Make_image(Points_Ims(i),32,32,1,1,5)
Next 
;blank
blank_im=Make_image(blank_im,6,24,1,1,6)
;make bombs
bomb_im=Make_image(bomb_im,1,30,1,1,7)
;bullets
bullet_im=Make_image(bullet_im,1,30,1,1,7)
;debri
For i = 0 To 15
	debri(i)=Make_image(debri(i),2,2,1,1,8)
Next 
;ufo
ufo_im=Make_image(ufo_im,100,100,.6,.35,9)

Goto skip_loop
SetBuffer BackBuffer()
While Not KeyHit(1)

;Cls
Text 0,0,"A image function By RiverRatt"
;players ship
DrawImage ship_im,MouseX(),MouseY()
;bases
For i = 0 To 14
	DrawImage im(i),60,50+i*30
Next
;bases
For i = 0 To 2 
	DrawImage bases(i),120,50+i*60
Next
;collision image
DrawImage bim,10,50
;points
For i = 0 To 15
	DrawImage Points_Ims(i),180,50+i*20
	
Next
;blank
DrawImage blank_im,200,50
;bombs
DrawImage bomb_im,230,50
;bullets
DrawImage bullet_im,240,50
;bullets
For i = 1 To 15
	DrawImage debri(i),260,50+i*3
Next
;ufo
DrawImage ufo_im,290,50
 
Flip 
Wend
End
.skip_loop

Function Make_image(image,width,height,scale_x#,scale_y#,index)
	
	
	image=CreateImage(width,height)
	SetBuffer ImageBuffer(image)
	MidHandle image
	Select (index)
		
			
		Case 1
			
			
			
			For l = 1 To 15
				Color 100-(l*5),100-(l*5),100-(l*5)

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

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

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

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

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

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

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

				Line 44-l,15,44-l,40
				Line 44+l,15,44+l,40
			Next
			For l = 1 To 5
				Color 50,50,50
				Line 3+(l/2),15-l,9-(l/2),15-l
				Line 41+(l/2),15-l,47-(l/2),15-l
			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 l = 1 To 4
				Color 60-l,60-l,60-l
				Line 3,41,9,41
				Line 41,41,47,41
				Line 3-Floor(l/2),41+l,9+Floor(l/2),41+l  ;rocket flares
				Line 41-Floor(l/2),41+l,47+Floor(l/2),41+l
			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 l = 1 To 5
				Color 120-(l*10),50,50   ;window with red light reflection on nose
				Line 23-l,16-l,27+l,16-l
			Next

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

			For l = 10 To 40 Step 5 ;some back detail to break up the color a little
				Color 120,120,120
				Line 0+l,32,0+l,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 image,scale_x#,scale_y#
		DebugLog(image)  	
		Return image
		
		
		Case 2
			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
			ScaleImage image,scale_x#,scale_y#
		Return image
		
		Case 3
			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 
			ScaleImage image,scale_x#,scale_y#
			MaskImage image,255,0,255

		Return image
		
		Case 4 ;collision image
			ClsColor 0,0,0
			Cls
			Color 255,255,255
			Oval 8,8,8,8,True
 		Return image

		Case 5 ;points
			l=l+i
			
				Color 0,255-(l Shl 4), 0
				Oval 16-l,16-l,l Shl 1 ,l Shl 1,False
				Text 16,16,"10",True,True
			
		Return image 
		
		Case 6 ;blank image
			;MaskImage blank_im,255,0,255
			Color 255,0,255
			Rect 0,0,6,24,True
			Color 0,255,0
		Return image
		
		Case 7 ;bullets and bombs 
			Color 0,255,0
			For l = 0 To 31 
				If l And 1 Then Plot 0,l Else Plot 1,l
			Next 
			
		Return image
		
		Case 8 ;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
			Return image
		
		Case 9
				;rockets
			For l = 1 To 3
				Color 75-(10*l),75,75-(10*l)
				Line 25+l,60,25+l,95-(l*5) ;left rocket
				Line 25-l,60,25-l,95-(l*5)
				Line 75+l,60,75+l,95-(l*5) ;right rocket
				Line 75-l,60,75-l,95-(l*5)
			Next
			Line 25,60,25,70
			Line 75,60,75,70
			Color 175,75,75
			Line 25,65,25,95
			Line 75,65,75,95
			;mid section
			For l = 1 To 4 ;neck
 				Color 40,80,40
				Line 50+l,20+(l*7),50+l,100-(l*7) 
				Line 50-l,20+(l*7),50-l,100-(l*7)
			Next 
			For l = 1 To 4 ;neck highlight
				Color 70,100,70
				Line 50+l,20+(l*7),50+l,90-(l*7) 
				Line 50-l,20+(l*7),50-l,90-(l*7)
			Next 
			For l = 1 To 3
				Line 50+l,0+(l*10),50+l,60 
				Line 50-l,0+(l*10),50-l,60
			Next
 
			;wings
			For l = 1 To 25
				Color 55+l,75+(l*2),25+l
				Line 50-l,40+l,50-l,60+l
				Line 50+l,40+l,50+l,60+l
			Next 
			;wing tips
			Line 75,65,75,84
			Line 25,65,25,84
			For l = 1 To 25
				;Color 125-i,150-i,125-i
				Color 80-l,130-(l*3),50-l
				Line 75+l,65-l,75+l,85-Ceil(l*1.75)
				Line 25-l,65-l,25-l,85-Ceil(l*1.75)
			Next 
			;head
			Color 30,80,30
			For l = 1 To 10
				Line 50+Ceil(l/2),100-l,50-Ceil(l/2),100-l ;forhead
			Next 
			For l = 1 To 5
				Line 45+l,90-l,55-l,90-l 
			Next
			Color 25,25,25
			For l = 1 To 5
				Line 50+Ceil(l/2),97-l,50-Ceil(l/2),97-l ;forhead
			Next 
			Color 175,75,75
			Line 50,0,50,10 
			;center body and rocket centers
			Color 50,70,20
			Line 50,38,50,63 ;wings center line
			Color 70,90,70
			Line 50,10,50,86
			For l = 1 To 75 Step 6
				Color 175-l,75-l,75-l
				Plot 50,0+l
			Next 
			Color 70,90,70
			Line 51,56,75,80
			Line 49,56,25,80
			Line 90,55,75,80
			Line 10,55,25,80

			ScaleImage image,scale_x#,scale_y#
			RotateImage image,90	
		Return image 
			
		Default
			image=CreateImage(255,50)
			SetBuffer ImageBuffer(image)
			MidHandle image

			Color 100,100,100
			Rect 0,0,255,50
			Color 1,1,1
			Text 0,20,"NO Index In Make_Image Function." 
			
			
			Return image 

		End Select 
		
End Function 



The game
;rewrite of some functions
;My make_image function included
Type Control_Type
	Field Max_Bombs
	Field Bomb_Speed
	Field Crit_Drop_Speed
	Field drop_bomb_chance
	Field Player_Speed
	Field Bullet_Speed
	Field Max_Rows
	Field Max_Cols
	Field XRes, YRes, Depth
	Field Beast_Speed#
	Field Beast_Speed_Increment#
	Field UFO_Speed
	Field Level
	Field NextExtraLife
End Type

Type points_type
	Field x,y
	Field id
End Type

Type explosion_type
	Field x,y
	Field speed
	Field status
	Field dirx,diry
	Field count
	Field id
End Type

Type HighScoreTable_Type
	Field score
	Field name$
End Type

Dim HighScores.HighScoreTable_type(10)
Global highscore.highscoretable_type
Dim SpaceyFont(40)

Type Player_Type
	Field x,y
	Field moved
	Field lives
	Field score
End Type

Type stars_type
	Field image
	Field x,y
	Field count
End Type

Type Beast_Type
Field x#,y#
Field deleted
End Type

Type Bullet_Type
	Field fired
	Field x,y
End Type

Type Bomb_Type
	Field fired
	Field x,y
	Field deleted 
End Type

Type UFO_Type
	Field x,y
	Field status
End Type

;*********************************
; Create and Set up Control Type
; This is used to manage all our game control variables,
; it's easier keeping them in one place and putting the set up at the start means we can 
; control the details in the rest of the set up from here on in

Global control.Control_Type
Set_Up_Control();1st function call

; Set graphics size
Graphics control\xres,control\yres,control\depth; These values have bin set in the function Set_Up_Control;1st function call
AutoMidHandle True;This comand makes the handle of all entities in this program controlled from its center of mass rather than its top left hand corner.

Include "Make_Image_dll_vers2.bb"
Dim stars.stars_type(3)

Global xp,yp
Global point.points_Type
Global dir# = control\beast_speed
Global score = 0
Global beast_count, total_beasts
Global x#, y#
Global EndGame = False
Global char$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 @#~"

Global explosion.Explosion_type
Global player.Player_Type
Global beast.Beast_Type
Global bullet.bullet_type
Global bombs.bomb_type
Global ufo.ufo_type = New ufo_type

player.Player_Type = New Player_Type	; create player



Make_Beasts()
Make_Stars()
Make_Player()
Make_Bullet()
Make_HighScoreTable()
Make_SpaceyFont()


SetBuffer BackBuffer(); Very important command. This sets up page fliping
;it is like cartoons, but you only have two pieces of paper,
;you draw something to the screen and then you use the Flip command to draw the next picture


quit = displaystartscreen()


While quit = False

	endgame = False
	
	old_level = 0 : control\level = 1 : control\nextextralife = 2500
	make_player()	
	While endgame = False

		If old_level <> control\level Then
			Introduce_Level()
			StartNewLevel()
			old_level = control\level
		End If
		
		If player\lives<=0 Then endgame =True 
		
		time# = MilliSecs()
		
		If player\score > control\nextextralife Then
			control\nextextralife = control\nextextralife + 2500
			player\lives = player\lives + 1
		End If

		Move_stars()	
		Display_Info(ship_im)
		af = (af + 1) And 15
	
		min_x = control\xres
		max_x = 0

		new_ufo()
		If ufo\status = True Then move_ufo(ufo_im)

		bomb_count = 0
		For bombs = Each bomb_type
			bomb_count = bomb_count + 1
			DrawImage bomb_im,bombs\x,bombs\y
			bombs\y = bombs\y + control\bomb_speed
		
			If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(0),192,400,0) Then
				SetBuffer ImageBuffer(bases(0))
				Color 0,0,0
				bxp = bombs\x - 168
				byp = bombs\y -368
				draw_blank (blank_im,bxp,byp)
				SetBuffer BackBuffer()
				Delete bombs
				bomb_count = bomb_count-1
			Else
				If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(1),320,400,0) Then
					SetBuffer ImageBuffer(bases(1))
					Color 0,0,0
					bxp = bombs\x - 288
					byp = bombs\y -368
					draw_blank (blank_im,bxp,byp)	
					SetBuffer BackBuffer()
					Delete bombs
					bomb_count = bomb_count-1
				Else
					If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(2),448,400,0) Then
						SetBuffer ImageBuffer(bases(2))
						Color 0,0,0
						bxp = bombs\x - 420
						byp = bombs\y -368
						draw_blank (blank_im,bxp,byp)
						SetBuffer BackBuffer()
						Delete bombs
						bomb_count = bomb_count-1
					Else	
						If ImagesCollide(bomb_im,bombs\x,bombs\y,0,ship_im,player\x,player\y,0) Then
							bomb_count=bomb_count-1
							Player\lives = player\lives-1
							Delete bombs
							For i = 0 To 10
								ClsColor Rnd(255),Rnd(255),Rnd(255)
								Cls
								Flip
							Next
						Else
							If bombs\y > 480 Then Delete bombs : bomb_count=bomb_count-1
						EndIf
					EndIf
				EndIf
			EndIf
		Next

	
		check_bullets_and_bases(blank_im,bullet_im)
	
		player\moved = False

		bomb_dropped = False
	
		beast_hit = False

		dokeys

		beast_count = 0
		For beast = Each beast_Type
			If beast\deleted = False Then
				beast_count = beast_count + 1
				x = beast\x + dir : y = beast\y
				If inc_y = True Then y = y + control\crit_drop_speed
				If dir > 0 Then
					If x > max_x Then max_x = x
				Else
					If x < min_x Then min_x = x
				EndIf
				
				If ImagesCollide(im(af), beast\x,beast\y,0,bases(0),192,400,0) = True Then 
					FreeImage bases(0) : bases(0) = CreateImage(1,1)
				Else If ImagesCollide(im(af), beast\x,beast\y,0,bases(1),320,400,0) = True Then
					 FreeImage bases(1) : bases(1) = CreateImage(1,1)
				Else If ImagesCollide(im(af), beast\x,beast\y,0,bases(2),448,400,0) = True Then
					FreeImage bases(2) : bases(2) = CreateImage(1,1)
				End If				
				beast\x = x
				beast\y = y

				DrawImage im(af),beast\x, beast\y
	
				If bullet\fired = True Then
					If ImagesCollide(im(af),beast\x,beast\y,0,bim,bullet\x,bullet\y,0) Then

						Add_Point (beast\x,beast\y)
						player\score = player\score + 10
					
						beast_count = beast_count-1 : beast_hit = True
					
						Make_Explosion (beast\x,beast\y,5)	
									
						beast\deleted = True
						bullet\fired = False
					EndIf
				EndIf
			
				If bomb_dropped = False Then
					If bomb_count < control\max_bombs Then
						If Rand(100)<control\drop_bomb_chance Then
							bomb_count = bomb_count+1
							bomb_dropped = True
							bombs = New bomb_type
							bombs\x = beast\x : bombs\y = beast\y
						EndIf
					EndIf
				EndIf
				
			EndIf
			
			If beast\y > 460 Then endgame = True
		Next
	
		If beast_hit = True Then Increase_Beast_Speed()
  
		inc_y = False
		If dir >0 Then
			If max_x > 608 Then dir = -dir : inc_y = True
		Else
			If min_x < 32 Then dir = - dir : inc_y = True
		EndIf

		Do_Points()	
		DoExplosion()
		If ufo\status = True Then Check_Bullets_And_Ufo(ufo_im,bullet_im)
		Move_And_Draw_Bullet(bullet_im)
	
		If beast_count = 0 And ufo\status = False Then control\level = control\level + 1
		
		DrawImage ship_im,player\x,player\y

		DrawImage bases(0),192,400
		DrawImage bases(1),320,400
		DrawImage bases(2),448,400
	
		Color 255,255,255
	
		Flip
	Wend
	
	DisplayEndScreen()
	EnterHighScore()
	endgame = False
		
	Delay(500)
	FlushKeys
	
	quit = displaystartscreen()	
Wend
End

;first function call
Function Set_Up_Control()
control.Control_Type = New Control_Type
control\max_bombs = 4
control\bomb_speed = 4
control\crit_drop_Speed = 4
control\drop_bomb_chance = 5
control\player_speed = 4
control\bullet_speed = 24
control\max_rows = 7
control\max_cols = 11
control\xres = 640 ; Try this pair at different resolution: 640,480 or 1024,768 or 1280,1024
control\yres = 480; 
control\depth = 16;
control\level = 1
control\Beast_Speed = 1
control\Beast_Speed_Increment = 0.05
control\UFO_Speed = 4
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 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
	If Rand(100) < 10 Then
		ufo\status = True
		ufo\x = 640
		ufo\y = 32
	EndIf
EndIf

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_Bullet()
; This creates the players bullet used throughout the whole game
	bullet = New bullet_type	; create bullet
	bullet\fired = False		; set that it's not been fired
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 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 DisplayStartScreen()
SetBuffer BackBuffer()
screentimer# = MilliSecs()
display_highscore = False

done = False : quit = False
While Not done
	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 Introduce_Level()
timer# = MilliSecs()
While MilliSecs()<timer + 500
	Cls
	Move_Stars()
	SpaceyText (300,200,"Level : " + control\level, True)
	Flip
Wend
End Function

Function StartNewLevel()
	Make_Beasts()
	
	;Make_Bases()
	For i = 0 To 2
		bases(i)=Make_image(bases(i),64,32,1,1,3)
	Next 

	
	control\Beast_Speed = 1+ (control\level/2)
	dir = control\beast_speed
	SetBuffer BackBuffer()

End Function

Function 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 Display_Info(ship_im)
	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 Move_Ufo(ufo_im)
	ufo\x = ufo\x - control\ufo_speed
	If ufo\x < 0 Then
		ufo\status = False
	EndIf
	DrawImage ufo_im,ufo\x,ufo\y
End Function

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

Function Check_Bullets_And_Bases(blank_im,bullet_im)
	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
				bullet\fired = False
				SetBuffer ImageBuffer(bases(i))
				xp = bullet\x - (160 + (i * 128))
				yp = bullet\y - 384
				draw_Blank (blank_im,xp,yp)
				SetBuffer BackBuffer()
			EndIf
			If bullet\fired = False Then Exit
		Next

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

Function DoKeys()

If KeyDown(57) Then
	If bullet\fired = False Then
		bullet\x = player\x : bullet\y = 460
		bullet\fired = True
	EndIf
EndIf

If player\moved = False Then
	If KeyDown(205) Then
		If player\x < 608 Then player\x = player\x + control\player_speed : player\moved = True
	EndIf
		
	If KeyDown(203) 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 Add_Point(x,y)
	point = New points_type
	point\x = x : point\y = y
	point\id = 0
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 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 DoExplosion()
For explosion = Each explosion_type
	DrawImage debri(explosion\id), explosion\x, explosion\y
	Select explosion\status
		Case 0
			explosion\dirx = Int(Rand(2))-1
			explosion\diry = Int(Rand(2))-1
			explosion\status = 1
			explosion\count = 10
		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
End Function

Function Check_Bullets_And_UFO(ufo_Im,bullet_im)
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
		EndIf
	EndIf
EndIf
End Function

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

Function DisplayEndScreen()
	FlushKeys
	screentimer = MilliSecs()
	While MilliSecs()<screentimer+2000
		Cls
		Move_Stars()
		SpaceyText (200,400,"GAME OVER",True)
		Flip
	Wend
	FlushKeys
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)
		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 Increase_Beast_Speed()
If dir < 0 Then 
	dir = dir - control\beast_speed_increment	
Else
	dir = dir + control\beast_speed_increment	
EndIf
End Function

Function SpaceyText(x,y,message$,centre);Called from the start and end screen setups not main
If Len(message)>0 Then
	If centre = True Then
		length = Len(message) * ImageWidth(spaceyfont(0))
		xs = (640-length)/2
	Else
		xs = x
	End If
	
	For c = 1 To Len(message)
		v = 0
		ch$ = Mid$(Upper(message), c, 1)
		If ch>="0" And ch<="9" Then 
			v = 26 + Asc(ch)-48
		Else If ch>="A" And ch<="Z" Then 
			v = Asc(ch)-65
		Else
			v = 36
		End If
		
		DrawImage spaceyfont(v),xs + (c * ImageWidth(spaceyfont(0))), y
	Next			
End If
End Function




Wow, that bad aye?

Greetings Puppies,

@RiverRatt: I was in the middle of replying when my wife demanded my attention so you lost out as I got distracted ;0)

The above is an Include, as opposed to a DLL and just separates the graphics creation from the main logic, yeah? That's fine, I'll give it a go later.

I've coded some bonus stuff in which I'll put up later - I think I've put in base rebuilding, extra lives, speed up, cluster bombs and a couple of other things too.

Peace,

Jes

Uh? I kinda thought a Dll was just another name for an include? Whats the difference?

A dll is a pre-compiled library that you can use just by knowing how to call the functions 'hidden' inside it (i.e. you never need to see the code.)

An include is just a fancy way of 'cutting and pasting' a big chunk of code into another listing - it gets compiled at the same time as your own code (so you can get a peek at it if you want to... and make changes !)

There are other subtleties, such as shared memory, etc. but the bit above is basically what its all about

So a dll would be something you would put in the blitz userlib folder?

Yes... But as long as you know the path to the dll you can really put it anywhere (the .decls file would need to go in userlib. Of course, since you are likely to be using relative paths and putting the dll into the same folder as the main code (when distributing to users) it makes sense to put both the .decls and .dll in the same place.

You cannot create a dll with blitz. Most people around here seem to use PureBasic. Most dll work I have done used Borland Delphi or C++ Builder (just because I know them.) Ironically, in the last project I distributed I forgot to include the Borland Runtime dll and so about half of my testers couldn't use the editor i had supplied to them :-(

Greetings Puppies,

Here is the code as mentioned above. Sorry for the delay but I've been rebuilding my computer.

Is there anything else to do with this?

Peace,

Jes

I am a little disapointed you do not want to use the code I modified for the include. It would have managed building new levals with different ships and bullet upgrades. But you must have your reasons.

I'll try to work on some stuff tommorrow. I've been really busy currently. It's coming along great, though!

No Enemies: Are you working on this? If so what are you going to do? Just asking so don't work on the same thing.

I want to work on this, but I'm much too busy (coding three games, a forums system, and developing an entire website with the "personality" of BlitzCoder takes up some time), and I was never that great with 2D. If I have the time, I'll work on a small 3D game. I've always wanted to start a community project, or contribute to one, but never found the time. :(

Well if that's all ya got going on, you should have this done in no time.

There does not seem to be anyone interested in working on this game.
I have a 3d spaceinvaders type game, 70% done. It just needs some changes here and there. Has a built in particle system, (from JFK), several models (a few that need textures), and a bunch of other things.
Alot of what it needs could be taken from this one.

I will post some sceenshots later, then if
anyones interested I will post the game.





I was just wondering, how do you make that with no media? Is that just shapes blitz shapes?

This one has media. I'm not <that> good. I also have some mother ships and other stuff made for it, but I have lost intrest so if people want to finish it I'll post the code, but I don't have web space for the models.

Post it RiverRatt, please.

/Alienforce

Sorry the code is very messy. You will need some models for ships, rocks, and some texutures, and sprites, there is no game timing yet and there is a bug reguarding the explotions but not until you get to the higher levals. No fatal bugs but sometimes the explotions don't show up. I think it is because of the particle system by JFK. It recycles the particles but sometimes more are needed than are available. An easy fix.
I can email the models I guess but they are not that great.

;revised for target pivot


Graphics3D 640,480,16
SetBuffer BackBuffer() 
AutoMidHandle True
;Set up random generator
SeedRnd MilliSecs()

 


;set up for colitions for skyphere,player_ship,player_shield,enemyship1

; Set collision type values 
type_player1=1 ;the player ship
type_bullet=2 
type_scenery=3 ;the skysphere
type_enimy=5
type_e_bullet=6
type_waypoint=7
;type_shieldpower=8

Global skysphere = CreateSphere(16,0)
ScaleEntity skysphere,-1500,-1500,-1500
EntityType skysphere,type_scenery
EntityOrder skysphere,1 
stars= LoadTexture("stars.bmp")
ScaleTexture stars,.135,.135
EntityTexture skysphere,stars
EntityFX skysphere,32

;grid_tex=CreateTexture( 32,32,8 )
;ScaleTexture grid_tex,10,10
;ScaleTexture grid_tex,10,10

;SetBuffer TextureBuffer( grid_tex )
;Color 0,0,64:Rect 0,0,32,32
;Color 0,0,255:Rect 0,0,32,32,False
;SetBuffer BackBuffer()

;plane = CreatePlane()
;EntityTexture plane,grid_tex

;The player ship_______________________________________
Global player_ship = LoadAnimMesh("Rat_Hunter.b3d")
HideEntity player_ship
EntityShininess player_ship,1
ScaleEntity player_ship,1.75,1.75,1
RotateEntity player_ship ,0,180,0
;player colition_____________________________________________________ 
EntityRadius player_ship,1.75
EntityBox player_ship,-1.75,-1.75,-1.75,2.50,2.50,2.50
;EntityType player_ship,type_player1

;______________________________________________________
Global player_shield = CreateSphere()
EntityColor player_shield,30,130,160
EntityAlpha player_shield,.3
EntityShininess player_shield,1
ScaleEntity player_shield,5,3,5
;player colition_____________________________________________________ 
EntityRadius player_shield,1.75
EntityBox player_shield,-1.75,-1.75,-1.75,2.50,2.50,2.50
;EntityType player_shield,type_player1
Global pivot = CreatePivot() 
EntityType pivot,type_player1
HideEntity player_shield

;player rocket_________________________________________
;baseblue = LoadTexture("baseblue.bmp")
;Global rocket1=LoadMesh("rocket.b3d")
Global rocket1=LoadMesh("plasma.3ds")

;Global rocket1=CreateSprite()

;blueflare=LoadTexture ("flame3.bmp")
;EntityTexture rocket1,blueflare
RotateMesh rocket1,90,0,0

;SpriteViewMode sprite,view_mode
;SpriteViewMode rocket1,3
 
;LightMesh mesh,red#,green#,blue#[,range#][,light_x#][,light_y#][,light_z#]
;LightMesh rocket1,200,100,100,10000
EntityFX rocket1,.5
EntityColor rocket1,255,10,10
;EntityShininess rocket1,.5 
;EntityTexture rocket1,baseblue
;RotateEntity rocket1,0,180,0
ScaleEntity rocket1,3,3,7
HideEntity rocket1

;enemy ship_______________________________________________
Global enemy_ship_1 = LoadMesh("spacefighter.b3d")
;EntityFX enemy_ship_1,(1+2)

EntityShininess enemy_ship_1,1 

PositionEntity enemy_ship_1,40,40,40
RotateEntity enemy_ship_1,0,180,0
HideEntity enemy_ship_1
;Global enemy_bullet = CreateSprite()
;Global player_bullet = CreateSprite()

;enemy ship2_______________________________________________
Global enemy_ship_2 = LoadMesh("dragonwing.b3d")
;EntityFX enemy_ship_1,(1+2)
ScaleEntity enemy_ship_2,2,2,2

EntityShininess enemy_ship_2,1 

PositionEntity enemy_ship_2,40,40,40
;RotateEntity enemy_ship_1,0,180,0
HideEntity enemy_ship_2
;Global enemy_bullet = CreateSprite()
;Global player_bullet = CreateSprite()


;constants______________________________________________________________________________________________

;Globals________________________________________________________________________________________________
Global player_x#
Global player_y#
Global player_z#
Global enemy_x#
Global enemy_y#
Global enemy_z#
;create timer variable for the enemies
;my personal tags for objects e_ = enemies, p_ = player, b_ = bullets


Global e_changedirection = 2000 
Global e_firetime = 2000
Global e_timerbegin = MilliSecs()
Global e_timeractive = 0
Global b_timeractive = 0 
Global b_timerbegin = MilliSecs()
;p_alpha# controls the alpha of the player shield
;when player is hit it becomes more transparant when p_alpha is 0 shield is gone and if hit again player
;will die, die ,die he,he, whoaaaaaa!
Global p_alpha#=.5
Global p_timerbegin = MilliSecs()
Global p_firetime=200
Global p_timeractive = 0 

Global rem_enemies
Global leval = 1

 
;Global cube1=CreateCube();when player colides with this entity dificulty is incromented by 1
Global cube1=CreateCube();and new enemies are created
ScaleEntity cube1,200,200,.5
;EntityColor cube1,220,220,220
EntityTexture cube1,stars
;RotateEntity cube1,0,180,0
;EntityFX cube1,32
EntityAlpha cube1,0
;EntityColor cube1,10,10,200
PositionEntity cube1,0,0,4000
EntityBox cube1,-75,-75,-1,150,150,.25
EntityType cube1,7 

icetex=LoadTexture("Clone of icytex.bmp")
;ScaleTexture icetex, 5.5,5.5

cube2=CreateCube()
ScaleEntity cube2,2,20,2 
;EntityTexture cube2,icetex
PositionEntity cube2,75,10,0 

cube3=CreateCube()
ScaleEntity cube3,2,20,2 
PositionEntity cube3,-75,10,0 

cube4=CreateCube()
ScaleEntity cube4,2,20,2 
PositionEntity cube4,-75,10,200

cube5=CreateCube()
ScaleEntity cube5,2,20,2 
PositionEntity cube5,75,10,200

Global iceblock1= LoadMesh("icyblock3.b3d")
;Global iceblock1= LoadMesh("mantle.3ds")

;RotateMesh iceblock1,-90,0,0
ScaleEntity iceblock1,15,10,15
PositionEntity iceblock1,-35,0,2000
EntityType iceblock1,3
HideEntity iceblock1
EntityTexture iceblock1,icetex

;RotateEntity iceblock1,90,0,0
;EntityAlpha iceblock1,1
;EntityFX iceblock1,16

Global shieldpower = LoadAnimMesh("shieldpower.b3d")
ScaleMesh shieldpower,2,2,2
PositionEntity shieldpower,0,4,30 

Global weaponpower1 = LoadAnimMesh("shieldpower.b3d")
EntityColor weaponpower1,255,0,0 
;Animate shieldpower,1,.125
;load\create meshes___________________________________________________________________________________
;create the backround________________________________________________________________________________
;load sprite :sprite handle to be passed to function
; *************  CSP Particle Engine Initialisation *************
;
Global CSPfire_max=500
Global CSP_FX_base,CSP_tt,CSP_ttold
Global CSP_GFXcard_crappiness#=.1
Dim CSPfire(CSPfire_max),CSPfire_fx(CSPfire_max),CSPfire_a#(CSPfire_max),CSPfire_s#(CSPfire_max),CSPfire_al#(CSPfire_max),CSPfire_s_min#(CSPfire_max),CSPfire_s_max#(CSPfire_max),CSPfire_s_mid#(CSPfire_max),CSPfire_speed#(CSPfire_max),CSPfire_livespan(CSPfire_max),CSPfire_lift#(CSPfire_max),CSPfire_mainalpha#(CSPfire_max),CSPfire_handle(CSPfire_max)

sprite_file$="theeyw.bmp"
Global tex=LoadTexture(sprite_file$,4)
Global tex2=LoadTexture("firesprite.bmp",4)
;Usage:
;CSP_LaunchParticle(fx, texture, n_sprites, x,y,z, min_size, max_size, speed, livespan,blendmode,random_rotation,heat_lift,main_alpha)

;Parameters:
;fx = Effect Selection (currently only 0)
;n_sprites = Number of sprites used for this Particle Launch
;xyz = xyz :)
;min_size = Particle start this size
;maxsize = particles end this size
;speed = growing speed
;livespan = time a launched particle will live
;blendmode = entityblendmode used
;random_rotation = flag rotate sprites initially randomly
;heat_lift = "Particle will fly upwards in the air"-speed
;main_alpha = main transparency
;
;Call "CSP_UpdateParticles()" once right before Renderworld() in the Mainloop
;
;*********** end of CSP Particle Engine Initialisation ************

    
;types initializations___________________________________________________________________________________
;player type
Type player
 Field x
 Field y
 Field z
 Field x_speed#
 Field y_speed#
 Field z_speed#
 Field speeder
 Field shield ; the players shield ,a sphere
 Field alive
 Field health
 Field shield_health
 Field p_pivot
 Field cam
 Field lite1
 Field lite2
 Field microphone
 Field sound
End Type

Type ship_flame
	Field obj,speed#,count#,untildist#,prescale#,scaledown#,alphadown#,alphacn#
End Type
 

Type enemy
 Field x
 Field y
 Field z
 Field x_speed#
 Field z_speed#
 Field ship
 Field alive
 Field health
 Field shield_health
End Type 

Type bullet
 Field x
 Field y
 Field z
 Field speed#
 Field damage
 Field from ;1= player, 2= enemy
 Field mesh
End Type

Type e_bullet
 Field x
 Field y
 Field z
 Field speed#
 Field xspeed#
 Field damage
 Field from ;1= player, 2= enemy
 Field mesh
End Type

Type explosion
 Field x#
 Field y#
 Field z#
 Field from;1player,2enemy
End Type  

Type astroid
 Field x
 Field y
 Field z
 Field turnspeed
 Field mesh
 Field selectmesh
 Field pivot
 Field powerup 
End Type

Type powercrystal
 Field x
 Field y
 Field z
 Field kind;1 for shield, 2 for weapons, 3 for other weapon, ect...
 Field mesh;to be determand by kind
End Type 
Global sound=LoadSound("engens.wav") 
SoundVolume sound,100

makeplayer()
;the makeenemy() function will be iterated depending on how high the leval is and create ships depending on leval number
makeenemy();this function will be moved to the initialise leval function not created yet
makeastroid()

;set up for collision checking
Collisions type_player1,type_enimy,3,2
;Collisions type_player1,type_player1,1,1
Collisions type_bullet,type_enimy,1,1
Collisions type_bullet,type_scenery,2,1
Collisions type_player1,type_scenery,2,1
Collisions type_enimy,type_enimy,1,3
Collisions type_enimy,type_scenery,2,1
Collisions type_e_bullet,type_player1,1,1
Collisions type_e_bullet,type_scenery,2,1
Collisions type_player1,type_waypoint,2,2


;Main Game Loopvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
While Not KeyHit(1)
 
 TurnEntity skysphere,-.03,.02,0
 ;TurnEntity iceblock1,0,1,0 
 If KeyDown(57) Then	
		p_createbullet
 EndIf
 ;wormtime=wormtime+1
;If wormtime = 100 Then
;CSP_LaunchParticle(fx,texture,n_sprites, x,y,z, min_size,max_size,speed, livespan,blendmode,random_rotation, heat_lift,main_alpha,emiter)
	;CSP_LaunchParticle(0,tex,1, 0,0,-4, 65,175,1, 5,3,0, 0,.5,cube1) ; nebula fog in blendmode 3
	;wormtime=0
;EndIf 
If KeyHit(10) Then 
SaveBuffer(FrontBuffer(),"screenshot.bmp") 
End If 


 updateplayer()
 enemy_ai()
 p_updatebullets()
 e_updatebullets()
 updateastroids()
 CSP_UpdateParticles()


UpdateWorld()
testcollisions()
TurnEntity cube1,0,0,-1 

;Print "Your available video memory is: " + AvailVidMem() 
;Print "Total graphics memory available: " + TotalVidMem () + " bytes." 
RenderWorld()
;Text 10,10,"player z " + player_z#
;Text 10,30,"next leval "+ EntityZ(cube1)
;Text 10,60," leval "+leval
;Text 10,80,player_x# + " " + player_y# + " " + player_z#  
 Flip False  


If KeyHit(25)=True Then
	While Not KeyHit(25)
	 KeyHit(25)=False
	 SetBuffer FrontBuffer()
	 Text GraphicsWidth()/2-40,GraphicsHeight()/2,"Pause"
	Text 0,20,"Triangles Rendered: "+TrisRendered() 

	Wend
	SetBuffer BackBuffer() 
EndIf
 


Wend;end of main game loop^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

removeastroids()
removeenemies()
removepowerups()
removeplayer()
ClearWorld()
End


;functions___________________________________________________________________________________________
; functions required for CSP Particles:
;CSP_LaunchParticle(fx, texture, n_sprites, x,y,z, min_size, max_size, speed, livespan,blendmode,random_rotation,heat_lift,main_alpha)
Function CSP_LaunchParticle(fx, texture, nof_sprite, x#, y#, z#, min_size#, max_size#, speed#, livespan,blend,rand_rot#,lift#,alpha#,emiter)
 If nof_sprite>200 Then nof_sprite=200 
 If fx=0 ; mush fx
  For i=CSP_FX_base To CSP_FX_base+nof_sprite
   If CSPfire(i)=0 Then  ; using this sprite the first time
    CSPfire(i)=CreateSprite(emiter)
	
    CSPfire_handle(i)=CSPfire(i)
   EndIf
   If CSPfire(i)=-1 Then ; or recycle this sprite
    CSPfire(i)=CSPfire_handle(i)
    ShowEntity CSPfire(i)
   EndIf
   PositionEntity CSPfire(i),x,y,z
   ;MoveEntity CSPfire(i),Rnd(-0.1,0.1),Rnd(-0.1,0.1),Rnd(-0.1,0.1)
   MoveEntity CSPfire(i),0,0,1
   CSPfire_s#(i)=1
   CSPfire_s_min#(i)=min_size#
   CSPfire_s_max#(i)=max_size#
   CSPfire_s_mid#(i)=CSPfire_s_min#(i)+(CSPfire_s_max#(i)-CSPfire_s_min#(i))/2
   If rand_rot<>0 Then CSPfire_a#(i)=Rand(360)
   CSPfire_al#(i)=0.0
   EntityTexture CSPfire(i),texture;TexTexTexTexTexTexTexTexTexTexTexTexTexTexTexTexTexTex
  
   EntityBlend CSPfire(i),blend
   CSPfire_s(i)=1+((CSPfire_s_max#(i)-CSPfire_s_min#(i))/(nof_sprite+1))*(i-CSP_FX_base)
   RotateSprite CSPfire(i),CSPfire_a(i)
   
   ;EntityAlpha CSPfire(i),0
   CSPfire_speed#(i)=speed#
   CSPfire_livespan(i)=livespan
   CSPfire_lift#(i)=lift#
   CSPfire_mainalpha#(i)=alpha#
   CSPfire_fx(i)=fx
  Next
 EndIf
 ;If fx=1 ; ?
 ; ...other initialisations + FX...your job...
 ;EndIf
 CSP_FX_base=CSP_FX_base+nof_sprite+1
 If CSP_FX_base>CSPfire_max-100 Then CSP_FX_base=0
End Function

Function CSP_UpdateParticles()
 CSP_tt=MilliSecs() : CSP_GFXcard_crappiness#=(CSP_tt - CSP_ttold)/16.0 : CSP_ttold = CSP_tt
 For i=0 To CSPfire_max

  If CSPfire_livespan(i)>0
   If CSPfire_fx(i)=0 ; mush fx
    If CSPfire_s(i)>CSPfire_s_mid#(i) 
     CSPfire_al(i)=(Abs((CSPfire_s_max#(i)-CSPfire_s(i))/(CSPfire_s_max#(i)-CSPfire_s_mid#(i))))*CSPfire_mainalpha(i)
    Else
     CSPfire_al(i)=(1-Abs(((CSPfire_s_mid#(i)-CSPfire_s(i))/(CSPfire_s_mid#(i)-CSPfire_s_min#(i)))))*CSPfire_mainalpha(i)
    EndIf
    CSPfire_s(i)=CSPfire_s(i)+(CSPfire_speed(i)*CSP_GFXcard_crappiness#)
    If CSPfire_s(i)>CSPfire_s_max#(i)  Then 
     CSPfire_s(i)=CSPfire_s_min#(i)
     If CSPfire_livespan(i)>0 Then CSPfire_livespan(i)=CSPfire_livespan(i)-1
    EndIf
    If CSPfire_al(i)>1.0 And CSPfire_al(i)<10.0 Then CSPfire_al(i)=1.0
    If CSPfire_al(i)>100.0 Then CSPfire_al(i)=0.0
    If CSPfire_al(i)<0.0 Then CSPfire_al(i)=0.0
    ScaleSprite CSPfire(i),CSPfire_s(i),CSPfire_s(i)
    EntityAlpha CSPfire(i),CSPfire_al(i)
    EntityOrder CSPfire(i),0

    If CSPfire_lift(i)<>0
     MoveEntity CSPfire(i),0,CSPfire_lift(i)*CSP_GFXcard_crappiness#,0
     
    EndIf
   EndIf
  Else; Particle dies...
   If CSPfire(i)<>0 And CSPfire(i)<>-1 Then
    HideEntity  CSPfire(i) ; only hide it - will prevent Memory fragmentation and BSOD - no slowdown!
	
    CSPfire(i)=-1
   EndIf
  EndIf
 Next
End Function

;create the player____________________________________________________________________________________
Function makeplayer()

 p_ship.player = New player 
 p_ship\p_pivot = pivot
 EntityType p_ship\p_pivot,1
 EntityRadius p_ship\p_pivot,10
 EntityBox p_ship\p_pivot,-3,-3,-3,6,6,6
 p_ship\x# = 0
 p_ship\y# = 0
 p_ship\z# = 0
 p_ship\x_speed# = 0
 p_ship\x_speed# = 0
 p_ship\z_speed# = 0
 p_ship\speeder = CopyEntity(player_ship,p_ship\p_pivot) 
 p_ship\shield = CopyEntity(player_shield,p_ship\p_pivot)
 p_ship\cam = CreateCamera(p_ship\p_pivot)
  
 CameraZoom p_ship\cam,1.6
 CameraRange p_ship\cam,1,3000
 PositionEntity p_ship\p_pivot,0,4,0
 PositionEntity p_ship\cam,0,5,-25
 p_ship\alive = True
 p_ship\health = 100
 p_ship\shield_health = 100
 p_ship\lite1=CreateLight(2,p_ship\p_pivot)
 
 p_ship\microphone=CreateListener(p_ship\cam) ; Create listener, make it child of camera
 ;p_ship\sound=Load3DSound("engens.wav") ; Load 3D sound
 p_ship\sound=PlaySound(sound)
 ;p_ship\sound

 LightColor p_ship\lite1,255,255,255
 ;LightConeAngles p_ship\lite1,-1,30
 LightRange p_ship\lite1,2500
 PositionEntity p_ship\lite1,0,3,0
 ;p_ship\lite2=CreateLight(1,p_ship\p_pivot)
 ;LightRange p_ship\lite2,25
 ;LightConeAngles p_ship\lite2,10,30
 ;PositionEntity p_ship\lite2,0,3,0

 Animate p_ship\speeder ,2,.05,0,0
 PositionEntity skysphere,p_ship\x#,p_ship\y#,p_ship\z#
 PositionEntity cube1,0,0,4000

 
End Function 
;create the enimies___________________________________________________________________________________
Function makeenemy()

For i = 1 To 20+(leval*2) 
 e_ship.enemy = New enemy
 e_ship\x# = Rnd(-75,75);-35+(i*10)
 e_ship\y# = 3;Rnd(-75,75)
 e_ship\z# = Rnd((player_z#+1000),(player_z#+4000));+(i*20)
 e_ship\x_speed# = 0
 e_ship\z_speed# = -3
 e_ship\ship = CopyEntity(enemy_ship_1)
 ScaleEntity e_ship\ship,3,3,3
 e_ship\alive = True ;(a little misleeding) determens if there are any enemies left 
 e_ship\health = 100+(leval*10)
 PositionEntity e_ship\ship,e_ship\x#,e_ship\y#,e_ship\z#;temporary
 ;enimy colition______________________________________________________
 EntityRadius e_ship\ship,3
 EntityBox e_ship\ship,-3,-3,-3,6,6,6
 EntityType e_ship\ship,5
Next

	 
; if player is on leval two or above ad more enemies_________________________________________________
If leval=>2 Then 
For i = 1 To 5
 e_ship_2.enemy = New enemy
 e_ship_2\x#=-75+(i*30)
 e_ship_2\y#=2
 e_ship_2\z#=EntityZ(cube1)+100
 e_ship_2\x_speed#=4
 e_ship_2\z_speed#=1
 e_ship_2\ship=CopyEntity(enemy_ship_2)
 e_ship_2\alive=True 
 e_ship_2\health = 300+(leval*50)

 PositionEntity e_ship_2\ship,e_ship_2\x#,e_ship_2\y#,e_ship_2\z#
 ;enimy colition______________________________________________________
 EntityRadius e_ship_2\ship,3
 EntityBox e_ship_2\ship,-3,-3,-3,6,6,6
 EntityType e_ship_2\ship,5

Next 
EndIf
If leval=>4 Then 
For i = 1 To 5
 e_ship_2.enemy = New enemy
 e_ship_2\x#=-75+(i*30)
 e_ship_2\y#=2
 e_ship_2\z#=EntityZ(cube1)+120
 e_ship_2\x_speed#=0
 e_ship_2\z_speed#=0
 e_ship_2\ship=CopyEntity(enemy_ship_2)
 e_ship_2\alive=True 
 e_ship_2\health = 300+(leval*50)

 PositionEntity e_ship_2\ship,e_ship_2\x#,e_ship_2\y#,e_ship_2\z#
 ;enimy colition______________________________________________________
 EntityRadius e_ship_2\ship,3
 EntityBox e_ship_2\ship,-3,-3,-3,6,6,6
 EntityType e_ship_2\ship,5

Next 

EndIf 
  
End Function

;update the enimies_____________________________________________________________________________________
Function enemy_ai() ;calculates enemy position, updates enemy, and when to fire bullets
For e_ship.enemy = Each enemy
 ;If the counter has run through, update the enemy velocities
 If MilliSecs() >= e_timerbegin + e_changedirection ;+ Rnd(600)
    e_ship\x_speed# = Rnd(-2,2) 
	e_ship\z_speed# = Rnd(-2,2) 
 	;make sure timer is reset
	e_timeractive = 0
 EndIf
 enemy_x#=EntityX(e_ship\ship)
 enemy_y#=EntityY(e_ship\ship)
 enemy_z#=EntityZ(e_ship\ship)
 
 
 If  enemy_x# < player_x# + (5+leval) And enemy_x# > player_x# - (5+leval) Then ;this will be adjusted per leval
	If MilliSecs() >= b_timerbegin + e_firetime 
		e_createbullet()
		b_timeractive=0
	EndIf 
 EndIf 

 If enemy_x# > 75 e_ship\x_speed# = -e_ship\x_speed# -.1
 If enemy_x# < -75 e_ship\x_speed# = -e_ship\x_speed# + .1
 If enemy_z# > player_z#+400 e_ship\z_speed# = -3
 If enemy_z# < player_z#+5 e_ship\z_speed# = Rnd(4,9)  
 If enemy_z# < (player_z#-100) Then 
	
	    
		PositionEntity e_ship\ship,e_ship\x#,e_ship\y#,EntityZ(cube1)
		CSP_LaunchParticle(0,tex,1, 0,0,-4, 65,175,1, 1,3,360, 0,.5,cube1) ; nebula fog in blendmode 3
	
	EndIf
 ;EndIf 
 For rock.astroid = Each astroid
 	If EntityDistance#(e_ship\ship,rock\pivot) < 10 Then
		If e_ship\x# < rock\x# Then ;move e_ship move ship to the left 
  			e_ship\x_speed# = - 2
		EndIf 
		If e_ship\x# > rock\x# Then ;move e_ship move ship to the left 
  			e_ship\x_speed# =  2
		EndIf 
	EndIf
 Next  
 TranslateEntity e_ship\ship,e_ship\x_speed#,0,e_ship\z_speed#
 If enemy_z# > (player_z# + 1000) HideEntity(e_ship\ship)
 If enemy_z# < (player_z# + 800)  ShowEntity(e_ship\ship)
 

 

 
Next

;If the timers are inactive, reset the timer 
If e_timeractive = 0
	e_timerbegin = MilliSecs()
	e_timeractive = 1
EndIf  
If b_timeractive = 0
	b_timerbegin = MilliSecs()
	b_timeractive = 1
EndIf  

End Function

;Test collisions______________________________________________________________________________________

;player bullet to enemy collision and player bullet to backround collision
Function testcollisions()
For p_rocket.bullet = Each bullet
 If p_rocket<>Null
   del=0
   If EntityCollided(p_rocket\mesh,5)
    del=1
   EndIf 
   If EntityCollided(p_rocket\mesh,3)
    del=1
   EndIf
  If del=1 Then 
   	FreeEntity p_rocket\mesh
	Delete p_rocket
	del=0
   EndIf
  EndIf 
Next

;enemy bullet to player colision and enemy bullet to backround collision
For e_rocket.e_bullet = Each e_bullet
 If e_rocket<>Null
   del=0
   If EntityCollided(e_rocket\mesh,3)
    del=1
   EndIf 
   If EntityCollided(e_rocket\mesh,1)
    del=1
   EndIf
  If del=1 Then 
   	FreeEntity e_rocket\mesh
	Delete e_rocket
	del=0
   EndIf
  EndIf 
Next


For e_ship.enemy = Each enemy
 If e_ship<>Null
	e_del=0
	If EntityCollided(e_ship\ship,3) Then
 		e_ship\x_speed# = -e_ship\x_speed#
 		e_ship\z_speed# = -e_ship\z_speed#
		e_ship\health=e_ship\health-100
		If e_ship\health < 0
			e_del=1
		EndIf 
	EndIf 

	If EntityCollided(e_ship\ship,2)
		e_ship\health = e_ship\health - 100   ;this number will be determaned by player bullet damage and the leval health of enemy
		If e_ship\health < 0
    		e_del=1
		EndIf 
    EndIf 
 EndIf 
 If e_del=1 Then 
   	If e_ship<>Null Then
		
		crystalexist=Rnd(1,5);not every ship will provide a powerup
		If crystalexist=5 Then ; a 1 in 5 chance for a destroyed ship to have a powercrystal
			powerup.powercrystal = New powercrystal
			powerup\kind = Rnd(1,3); decides which kind of crystal will apear. guns,shields,speed?
			Select True ;create the powerups_________________________________________________________
				Case powerup\kind = 1
					powerup\mesh = CopyEntity(shieldpower)
					ScaleEntity powerup\mesh,2,2,2
					Animate powerup\mesh,2,.125
				Case powerup\kind = 2
					powerup\mesh = CopyEntity(shieldpower)
					EntityColor powerup\mesh,0,255,255
					ScaleEntity powerup\mesh,2,2,2
					Animate powerup\mesh,2,.125
				Case powerup\kind = 3
					powerup\mesh = CopyEntity(shieldpower)
					EntityColor powerup\mesh,0,0,255
					ScaleEntity powerup\mesh,2,2,2
					Animate powerup\mesh,2,.125
			End Select
			EntityRadius powerup\mesh,2
			EntityType powerup\mesh,8 
			 

			powerup\x# = EntityX#(e_ship\ship)
			powerup\y# = EntityY#(e_ship\ship)
			powerup\z# = EntityZ#(e_ship\ship)
			 
            PositionEntity powerup\mesh,powerup\x#,powerup\y#,powerup\z# 
		EndIf
		;do explotion 
		;killedenemy.explosion = New explosion
		;killedenemy\x# = EntityX#(e_ship\ship)
		;killedenemy\y# = EntityY#(e_ship\ship)
		;killedenemy\z# = EntityZ#(e_ship\ship)
		;x#=killedenemy\x#
		;y#=killedenemy\y#
		;z#=killedenemy\z#
		x#=EntityX#(e_ship\ship)

		y#= EntityY#(e_ship\ship)

		z#= EntityZ#(e_ship\ship)

		;ship=e_ship\ship
		;call to create explotion at the ships location
		;CSP_LaunchParticle(fx, texture, n_sprites, x,y,z ,min_size,max_size,  speed,livespan,blendmode,random_rotation ,heat_lift,main_alpha,emiter)
		CSP_LaunchParticle(0, tex2, 1,x#,y#,z#, 3,15,.25 ,1,1,10 ,0,.5,0) ; nebula fog in blendmode 3



 		
		FreeEntity e_ship\ship
 		Delete e_ship
 	EndIf


 EndIf

 
Next

For powerup.powercrystal = Each powercrystal
If powerup<>Null
 	pow_del=0
	For p_ship.player = Each player
		If EntityDistance (p_ship\p_pivot,powerup\mesh)<15 Then 
	 		pow_del=1 
		EndIf
	Next 	
   If pow_del=1 Then   
		p_alpha#=.5
		FreeEntity powerup\mesh
		Delete powerup 
		pow_del=0

	EndIf
EndIf	 
Next  
 

For p_ship.player = Each player
 If p_ship<>Null
  If EntityCollided (p_ship\p_pivot,6) Then
	p_alpha#=p_alpha#-.005-(.001*leval);this be replaced with a variable for shield powerups
	EntityAlpha p_ship\shield,p_alpha#
	If p_alpha# < 0 
	   p_del=1
	EndIf 
	If p_del=1 Then ;free all entities and delete all bullets and restart leval
	   FreeEntity p_ship\speeder
	   FreeEntity p_ship\shield
	   FreeEntity p_ship\p_pivot
	   Delete p_ship
	  
	   p_del=0
	   ;SetBuffer FrontBuffer()
	   ;Text 300,300,"you died"
	   ;Text 200,320,"Pres the anykey to continue or escape to exit"
	   ;WaitKey()
	   Delay 2000
	   restart_leval()
	   
	EndIf
  EndIf
 EndIf  
Next 
;Collision Test for the player to the end leval box__________________________________________________ 
 
 For p_ship.player = Each player
 
	If EntityCollided (p_ship\p_pivot,7) Then 
		HideEntity cube1
		SetBuffer FrontBuffer()
		Cls 
		Text GraphicsWidth()/2,GraphicsHeight()/2,"leval " + leval + "Compete!"
        Delay 3000
	    PositionEntity cube1,0,0,EntityZ(p_ship\p_pivot)+4011
		PositionEntity p_ship\p_pivot,0,4,EntityZ(p_ship\p_pivot)
		PositionEntity p_ship\cam,0,5,-25
		leval=leval+1
		ShowEntity cube1
		removeastroids()
		removeenemies()
		removepowerups()
		makeastroid()
		makeenemy()
		SetBuffer BackBuffer()
 	EndIf


	
 Next
;For powerup.powercrystal = Each powercrystal
;If powerup<>Null
 	;pow_del=0
	;If EntityCollided (p_ship\p_pivot,8) Then
		;pow_del=1
	;EndIf
		
   ;If pow_del=1 Then   
		;p_alpha#=.5
		;FreeEntity powerup\mesh
		;Delete powerup 
		;pow_del=0

	;EndIf
;EndIf	 
;Next 



End Function


;free all entities and delete all bullets and restart current leval
Function restart_leval()
 
 For e_rocket.e_bullet = Each e_bullet
 	If e_rocket<>Null Then 
 		FreeEntity e_rocket\mesh 
 		Delete e_rocket 
 	EndIf
 Next
 
 For p_rocket.bullet = Each bullet
 	If p_rocket<>Null Then 
 		FreeEntity p_rocket\mesh 
 		Delete p_rocket 
 	EndIf
 Next 
 
 For e_ship.enemy = Each enemy
	If e_ship<>Null Then 
 		FreeEntity e_ship\ship
 		Delete e_ship
 	EndIf
 Next
 
 For p_ship.player = Each player
	If p_ship<>Null Then 
 	   FreeEntity p_ship\speeder
	   FreeEntity p_ship\shield
	   FreeEntity p_ship\p_pivot
	   FreeEntity p_ship\cam
	   FreeEntity p_ship\lite1

	   Delete p_ship

 		
 	EndIf
 Next
 For rock.astroid = Each astroid
    If rock<>Null Then 
		FreeEntity rock\mesh
		FreeEntity rock\pivot
		FreeEntity rock\powerup
		Delete rock
	EndIf 
 Next  

For i=0 To CSPfire_max-1
	If CSPfire(i)=True  

		FreeEntity CSPfire(i)
 	EndIf 
Next 

  
;While Not KeyHit(28)
;Wend
;make all the new entities___________________________________________________________________________
pivot = CreatePivot() 
EntityType pivot,type_player1
player_z#=0
makeastroid()
makeplayer()
makeenemy()
;reset timers and other global variables
 ;timeractive = 0
 p_alpha#=.5
 b_timeractive = 0 
 p_timeractive = 0 
 e_timeractive = 0
End Function


;create player bullets________________________________________________________________________________
Function p_createbullet.bullet()
If MilliSecs() >= p_timerbegin + p_firetime Then 
 p_rocket.bullet = New bullet
 p_rocket\x = player_x# 
 p_rocket\y = player_y# 
 p_rocket\z = player_z# 
 p_rocket\speed = 40
 p_rocket\damage = 20
 p_rocket\from = 1
 p_rocket\mesh = CopyEntity(rocket1);Rocket1 to start out but this will be changeable with a weapos select function
 EntityColor p_rocket\mesh,0,200,55
 PositionEntity p_rocket\mesh,player_x,player_y,player_z 
 ;bullet collision___________________________________________________________________________________
 EntityRadius p_rocket\mesh,5
 EntityBox p_rocket\mesh,-5,-5,-5,10,10,10
 EntityType p_rocket\mesh,2
 p_timeractive = 0

EndIf
If p_timeractive = 0
	p_timerbegin = MilliSecs()
	p_timeractive = 1
EndIf  

End Function
;update the payer bullets_____________________________________________________________________________
Function p_updatebullets.bullet()
 
 For p_rocket.bullet = Each bullet
	MoveEntity p_rocket\mesh,0,0,p_rocket\speed
 Next

 
End Function


;create enimy bullets___________________________________________________________________________________
Function e_createbullet()
 e_rocket.e_bullet = New e_bullet
 e_rocket\x# = enemy_x# 
 e_rocket\y# = enemy_y# 
 e_rocket\z# = enemy_z# 
 e_rocket\speed# = 10
 e_rocket\xspeed# = Rnd(-1,1)
 e_rocket\damage = 20
 e_rocket\from = 1
 e_rocket\mesh = CopyEntity(rocket1);Rocket1 to start out but this will be changeable with a weapos select function
 ;ScaleEntity e_rocket\mesh,7,7,7
 EntityColor e_rocket\mesh,250,10,0
 RotateEntity e_rocket\mesh,0,180,0
 PositionEntity e_rocket\mesh,e_rocket\x ,e_rocket\y-2 ,e_rocket\z  ;each enemy position
 ;bulet colition______________________________________________________
 EntityRadius e_rocket\mesh,5
 EntityBox e_rocket\mesh,-5,-5,-5,10,10,10
 EntityType e_rocket\mesh,6

End Function


;update the enimy bullets_____________________________________________________________________________
Function e_updatebullets.e_bullet()
 
 For e_rocket.e_bullet = Each e_bullet
	MoveEntity e_rocket\mesh,0,0,e_rocket\speed#
 Next

 
End Function




;update the backround___________________________________________________________________________________
;update the player____________________________________________________________________________________
Function updateplayer()
 For p_ship.player = Each player
  	
	
 
    
	
	If KeyDown(205) Then
	 	p_ship\x_speed# = p_ship\x_speed#+ .50
		If p_ship\x_speed# >= 1.5 Then p_ship\x_speed# = 1.5
	EndIf 
	If KeyDown(203)  Then
		p_ship\x_speed# = p_ship\x_speed# -.50
		If p_ship\x_speed# <= -1.5 Then p_ship\x_speed# = -1.5
	EndIf 
	If KeyDown(200)  Then 
		p_ship\z_speed#=p_ship\z_speed#+.75
		If p_ship\z_speed# >= 10 Then p_ship\z_speed# = 15

	EndIf 
	If KeyDown(208)  Then 
		p_ship\z_speed#=p_ship\z_speed#-.50
		If p_ship\z_speed# <= -1.50 Then p_ship\z_speed# = -1.50
	EndIf 

	
	
	
	If EntityCollided(p_ship\p_pivot,3) Or EntityCollided(p_ship\p_pivot,5) Then
	 	p_ship\x_speed#=-p_ship\x_speed#*.50
	 	p_ship\z_speed#=-p_ship\z_speed#*.50
		TranslateEntity p_ship\cam,2*(-p_ship\x_speed#*.25),0,0;-2*shipspeed*.25 presets the camera to keep it from incromenting off to the side
	Else     
	    TranslateEntity p_ship\cam,-p_ship\x_speed#*.25,0,0
	EndIf
	
	
	;If player_y# > 4.025 p_ship\y_speed#=-.025
	;If player_y# < 3.975 p_ship\y_speed#=.025
    If player_y# <> 4 PositionEntity p_ship\p_pivot,player_x#,4,player_z# 
	TranslateEntity skysphere,-p_ship\x_speed#,0,p_ship\z_speed#
	TranslateEntity p_ship\p_pivot,p_ship\x_speed#,p_ship\y_speed#,p_ship\z_speed#
	
	player_x# = EntityX(p_ship\p_pivot)
	player_y# = EntityY(p_ship\p_pivot)
	player_z# = EntityZ(p_ship\p_pivot)
    player_zspeed=Ceil(p_ship\z_speed#)

	;If ChannelPlaying(p_ship\sound) Then
	  
    ;PlaySound(sound)
	
	;EndIf 
	
	
	
     
    


 Next 

End Function 

;astroids ___________________________________________________________________________________________
Function makeastroid()
 For i = 1 To Rnd(6,12)
    
 	rock.astroid = New astroid
 	rock\x# = Rnd(-200,200)
 	rock\y# = 0;Rnd(-10,10)
 	rock\z# = (player_z#+1000) + Rnd(0,player_z#+2500)
	rock\pivot = CreatePivot()
 	rock\turnspeed# = Rnd(-1,1)
	rock\selectmesh = Rnd(4);this will be a variable that will choose between 4 rockmeshes from a rock leval set
 	rock\mesh = CopyEntity(iceblock1,rock\pivot)
   
    PositionEntity rock\pivot,rock\x,rock\y,rock\z
    PositionEntity rock\mesh,0,0,0
    EntityType rock\mesh,3
    
 Next

	

End Function

Function updateastroids()
 For rock.astroid = Each astroid
	TurnEntity rock\pivot,0,rock\turnspeed#,0
	If player_z# > rock\z# HideEntity(rock\mesh)
	If player_z# < rock\z# ShowEntity(rock\mesh) 
	
 Next
End Function
Function removeastroids()
 For rock.astroid = Each astroid
    If rock<>Null Then 
		FreeEntity rock\mesh
		FreeEntity rock\pivot
		Delete rock
	EndIf 
 Next  
End Function
Function removeenemies()
 For e_ship.enemy = Each enemy
	If e_ship<>Null Then 
 		FreeEntity e_ship\ship
 		Delete e_ship
 	EndIf
 Next
End Function
Function removepowerups()
 For powerup.powercrystal = Each powercrystal
	If powerup<>Null Then 
		FreeEntity powerup\mesh
		Delete powerup 
	EndIf
 Next 
End Function
Function removeplayer()
For p_ship.player = Each player

	FreeEntity p_ship\speeder
	FreeEntity p_ship\shield
	FreeEntity p_ship\p_pivot
	Delete p_ship
Next
End Function
 
	   



Thanks RiverRatt, I will look at it later on today.

/Alienforce

Shooting Sound Added
Gosub makeSound

Type Control_Type
	Field Max_Bombs
	Field Bomb_Speed
	Field Crit_Drop_Speed
	Field drop_bomb_chance
	Field Player_Speed
	Field Bullet_Speed
	Field Max_Rows
	Field Max_Cols
	Field XRes, YRes, Depth
	Field Beast_Speed#
	Field Beast_Speed_Increment#
	Field UFO_Speed
	Field Level
	Field NextExtraLife
End Type

Type points_type
	Field x,y
	Field id
End Type

Type explosion_type
	Field x,y
	Field speed
	Field status
	Field dirx,diry
	Field count
	Field id
End Type

Type HighScoreTable_Type
	Field score
	Field name$
End Type

Dim HighScores.HighScoreTable_type(10)
Global highscore.highscoretable_type
Dim SpaceyFont(40)

Type Player_Type
	Field x,y
	Field moved
	Field lives
	Field score
End Type

Type stars_type
	Field image
	Field x,y
	Field count
End Type

Type Beast_Type
Field x#,y#
Field deleted
End Type

Type Bullet_Type
	Field fired
	Field x,y
End Type

Type Bomb_Type
	Field fired
	Field x,y
	Field deleted 
End Type

Type UFO_Type
	Field x,y
	Field status
End Type

;*********************************
; Create and Set up Control Type
; This is used to manage all our game control variables,
; it's easier keeping them in one place and putting the set up at the start means we can 
; control the details in the rest of the set up from here on in

Global control.Control_Type
Set_Up_Control

; Set graphics size
Graphics control\xres,control\yres,control\depth
AutoMidHandle True

Dim im(15)
Dim bases(3)
Dim Points_Ims(16)
Dim debri(16)
Dim stars.stars_type(3)

Global bim 
Global ufo_im
Global ship_im 
Global bomb_im = CreateImage(2,32)
Global xp,yp
Global blank_im = CreateImage(6,24)
Global point.points_Type
Global bullet_im = CreateImage(2,16)
Global dir# = control\beast_speed
Global score = 0
Global beast_count, total_beasts
Global x#, y#
Global EndGame = False
Global char$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 @#~"

Global explosion.Explosion_type
Global player.Player_Type
Global beast.Beast_Type
Global bullet.bullet_type
Global bombs.bomb_type
Global ufo.ufo_type = New ufo_type

player.Player_Type = New Player_Type	; create player

Make_Collision_Image
Make_Player_Image
Make_Beast_Images
Make_Beasts
Make_Bases
Make_Points_Ims
Make_Blank
Make_Bombs
Make_Bullets
Make_Debri
Make_Stars
Make_Ship
Make_Ufo
Make_Player
Make_Bullet
Make_HighScoreTable
Make_SpaceyFont

SetBuffer BackBuffer()

quit = displaystartscreen()

While quit = False

	endgame = False
	
	old_level = 0 : control\level = 1 : control\nextextralife = 2500
	make_player	
	While endgame = False

		If old_level <> control\level Then
			Introduce_Level
			StartNewLevel
			old_level = control\level
		End If
		
		If player\lives<=0 Then endgame =True 
		
		time# = MilliSecs()
		
		If player\score > control\nextextralife Then
			control\nextextralife = control\nextextralife + 2500
			player\lives = player\lives + 1
		End If

		Move_stars	
		Display_Info
		af = (af + 1) And 15
	
		min_x = control\xres
		max_x = 0

		new_ufo
		If ufo\status = True Then move_ufo

		bomb_count = 0
		For bombs = Each bomb_type
			bomb_count = bomb_count + 1
			DrawImage bomb_im,bombs\x,bombs\y
			bombs\y = bombs\y + control\bomb_speed
		
			If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(0),192,400,0) Then
				SetBuffer ImageBuffer(bases(0))
				Color 0,0,0
				bxp = bombs\x - 168
				byp = bombs\y -368
				draw_blank bxp,byp
				SetBuffer BackBuffer()
				Delete bombs
				bomb_count = bomb_count-1
			Else
				If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(1),320,400,0) Then
					SetBuffer ImageBuffer(bases(1))
					Color 0,0,0
					bxp = bombs\x - 288
					byp = bombs\y -368
					draw_blank bxp,byp	
					SetBuffer BackBuffer()
					Delete bombs
					bomb_count = bomb_count-1
				Else
					If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(2),448,400,0) Then
						SetBuffer ImageBuffer(bases(2))
						Color 0,0,0
						bxp = bombs\x - 420
						byp = bombs\y -368
						draw_blank bxp,byp
						SetBuffer BackBuffer()
						Delete bombs
						bomb_count = bomb_count-1
					Else	
						If ImagesCollide(bomb_im,bombs\x,bombs\y,0,ship_im,player\x,player\y,0) Then
							bomb_count=bomb_count-1
							Player\lives = player\lives-1
							Delete bombs
							For i = 0 To 10
								ClsColor Rnd(255),Rnd(255),Rnd(255)
								Cls
								Flip
							Next
						Else
							If bombs\y > 480 Then Delete bombs : bomb_count=bomb_count-1
						EndIf
					EndIf
				EndIf
			EndIf
		Next

	
		check_bullets_and_bases
	
		player\moved = False

		bomb_dropped = False
	
		beast_hit = False

		dokeys

		beast_count = 0
		For beast = Each beast_Type
			If beast\deleted = False Then
				beast_count = beast_count + 1
				x = beast\x + dir : y = beast\y
				If inc_y = True Then y = y + control\crit_drop_speed
				If dir > 0 Then
					If x > max_x Then max_x = x
				Else
					If x < min_x Then min_x = x
				EndIf
				
				If ImagesCollide(im(af), beast\x,beast\y,0,bases(0),192,400,0) = True Then 
					FreeImage bases(0) : bases(0) = CreateImage(1,1)
				Else If ImagesCollide(im(af), beast\x,beast\y,0,bases(1),320,400,0) = True Then
					 FreeImage bases(1) : bases(1) = CreateImage(1,1)
				Else If ImagesCollide(im(af), beast\x,beast\y,0,bases(2),448,400,0) = True Then
					FreeImage bases(2) : bases(2) = CreateImage(1,1)
				End If				
				beast\x = x
				beast\y = y

				DrawImage im(af),beast\x, beast\y
	
				If bullet\fired = True Then
					If ImagesCollide(im(af),beast\x,beast\y,0,bim,bullet\x,bullet\y,0) Then

						Add_Point beast\x , beast\y
						player\score = player\score + 10
					
						beast_count = beast_count-1 : beast_hit = True
					
						Make_Explosion beast\x,beast\y,5	
									
						beast\deleted = True
						bullet\fired = False
					EndIf
				EndIf
			
				If bomb_dropped = False Then
					If bomb_count < control\max_bombs Then
						If Rand(100)<control\drop_bomb_chance Then
							bomb_count = bomb_count+1
							bomb_dropped = True
							bombs = New bomb_type
							bombs\x = beast\x : bombs\y = beast\y
						EndIf
					EndIf
				EndIf
				
			EndIf
			
			If beast\y > 460 Then endgame = True
		Next
	
		If beast_hit = True Then Increase_Beast_Speed
  
		inc_y = False
		If dir >0 Then
			If max_x > 608 Then dir = -dir : inc_y = True
		Else
			If min_x < 32 Then dir = - dir : inc_y = True
		EndIf

		Do_Points	
		DoExplosion
		If ufo\status = True Then Check_Bullets_And_Ufo
		Move_And_Draw_Bullet
	
		If beast_count = 0 And ufo\status = False Then control\level = control\level + 1
		
		DrawImage ship_im,player\x,player\y

		DrawImage bases(0),192,400
		DrawImage bases(1),320,400
		DrawImage bases(2),448,400
	
		Color 255,255,255
	
		Flip
	Wend
	
	DisplayEndScreen
	EnterHighScore
	endgame = False
		
	Delay(500)
	FlushKeys
	
	quit = displaystartscreen()	
Wend
End

Function Set_Up_Control()
control.Control_Type = New Control_Type
control\max_bombs = 4
control\bomb_speed = 4
control\crit_drop_Speed = 4
control\drop_bomb_chance = 5
control\player_speed = 4
control\bullet_speed = 24
control\max_rows = 7
control\max_cols = 11
control\xres = 640 ; Try this pair at different resolution: 640,480 or 1024,768 or 1280,1024
control\yres = 480; 
control\depth = 16;
control\level = 1
control\Beast_Speed = 1
control\Beast_Speed_Increment = 0.05
control\UFO_Speed = 4
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
	If bullet\fired = False Then
		bullet\x = player\x : bullet\y = 460
		bullet\fired = True
		PlaySound shootSound
	EndIf
EndIf

If player\moved = False Then
	If KeyDown(205) Then
		If player\x < 608 Then player\x = player\x + control\player_speed : player\moved = True
	EndIf
		
	If KeyDown(203) 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(2))-1
			explosion\diry = Int(Rand(2))-1
			explosion\status = 1
			explosion\count = 10
		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
End Function

Function Check_Bullets_And_UFO()
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
		EndIf
	EndIf
EndIf
End Function

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

Function Check_Bullets_And_Bases()
	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
				bullet\fired = False
				SetBuffer ImageBuffer(bases(i))
				xp = bullet\x - (160 + (i * 128))
				yp = bullet\y - 384
				draw_Blank xp,yp
				SetBuffer BackBuffer()
			EndIf
			If bullet\fired = False Then Exit
		Next

		If bullet\y < 0 Then 
			bullet\fired = False
		EndIf
	EndIf
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()

	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
	If Rand(100) < 10 Then
		ufo\status = True
		ufo\x = 640
		ufo\y = 32
	EndIf
EndIf

End Function

Function Move_Ufo()
	ufo\x = ufo\x - control\ufo_speed
	If ufo\x < 0 Then
		ufo\status = False
	EndIf
	DrawImage ufo_im,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 = CreateImage(16,16)
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 Make_Bullet()
; This creates the players bullet used throughout the whole game
	bullet = New bullet_type	; create bullet
	bullet\fired = False		; set that it's not been fired
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
	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
		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)
		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()
	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
	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_Bases()
For i = 0 To 3
	bases(i) = CreateImage(64,32)
	MaskImage bases(i),255,0,255
	SetBuffer ImageBuffer(bases(i))
	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
Next	
End Function

Function Make_Bombs()
SetBuffer ImageBuffer(bomb_im)
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_Bullets()
SetBuffer ImageBuffer(bullet_im)
Color 0,255,255
For i = 0 To 15
	If i And 1 Then Plot 0,i Else Plot 1,i
Next 
End Function

Function Make_Ufo()
	ufo_im = CreateImage(100,100)
	;Color 0,255,0
	SetBuffer ImageBuffer(ufo_im)
	;rockets
For i = 1 To 3
	Color 75-(10*i),75,75-(10*i)
	Line 25+i,60,25+i,95-(i*5) ;left rocket
	Line 25-i,60,25-i,95-(i*5)
	Line 75+i,60,75+i,95-(i*5) ;right rocket
	Line 75-i,60,75-i,95-(i*5)
Next
Line 25,60,25,70
Line 75,60,75,70
Color 175,75,75
Line 25,65,25,95
Line 75,65,75,95
;mid section
For i = 1 To 4 ;neck
 	Color 40,80,40
	Line 50+i,20+(i*7),50+i,100-(i*7) 
	Line 50-i,20+(i*7),50-i,100-(i*7)
Next 
For i = 1 To 4 ;neck highlight
	Color 70,100,70
	Line 50+i,20+(i*7),50+i,90-(i*7) 
	Line 50-i,20+(i*7),50-i,90-(i*7)
Next 
For i = 1 To 3
	Line 50+i,0+(i*10),50+i,60 
	Line 50-i,0+(i*10),50-i,60
Next
 
;wings
For i = 1 To 25
	Color 55+i,75+(i*2),25+i
	Line 50-i,40+i,50-i,60+i
	Line 50+i,40+i,50+i,60+i
Next 
;wing tips
Line 75,65,75,84
Line 25,65,25,84
For i = 1 To 25
	;Color 125-i,150-i,125-i
	Color 80-i,130-(i*3),50-i
	Line 75+i,65-i,75+i,85-Ceil(i*1.75)
	Line 25-i,65-i,25-i,85-Ceil(i*1.75)
Next 
;head
Color 30,80,30
For i = 1 To 10
	Line 50+Ceil(i/2),100-i,50-Ceil(i/2),100-i ;forhead
Next 
For i = 1 To 5
	Line 45+i,90-i,55-i,90-i 
Next
Color 25,25,25
For i = 1 To 5
	Line 50+Ceil(i/2),97-i,50-Ceil(i/2),97-i ;forhead
Next 
Color 175,75,75
Line 50,0,50,10 
;center body and rocket centers
Color 50,70,20
Line 50,38,50,63 ;wings center line
Color 70,90,70
Line 50,10,50,86
For i = 1 To 75 Step 6
Color 175-i,75-i,75-i
Plot 50,0+i
Next 
Color 70,90,70
Line 51,56,75,80
Line 49,56,25,80
Line 90,55,75,80
Line 10,55,25,80

ScaleImage ufo_im,.5,.25
RotateImage ufo_im,90	
End Function

Function SpaceyText(x,y,message$,centre)
If Len(message)>0 Then
	If centre = True Then
		length = Len(message) * ImageWidth(spaceyfont(0))
		xs = (640-length)/2
	Else
		xs = x
	End If
	
	For c = 1 To Len(message)
		v = 0
		ch$ = Mid$(Upper(message), c, 1)
		If ch>="0" And ch<="9" Then 
			v = 26 + Asc(ch)-48
		Else If ch>="A" And ch<="Z" Then 
			v = Asc(ch)-65
		Else
			v = 36
		End If
		
		DrawImage spaceyfont(v),xs + (c * ImageWidth(spaceyfont(0))), y
	Next			
End If
End Function

;Becky Roses wierd way of doing sound in code
.shoot
Data 4810
Data 82,73,70,70,194,18,0,0,87,65,86,69,102,109,116,32,18,0,0,0,1,0,1,0,64,31,0,0,64,31,0,0,1,0,8,0,0,0,102,97,99,116,4,0,0,0,143,18,0,0,100,97,116,97,143,18,0,0,126,163,97,101,124,137
Data 134,110,112,120,154,131,117,116,152,132,141,155,80,104,221,66,135,200,59,112,244,129,56,188,155,61,114,208,47,88,198,89,59,162,204,46,109,207,113,84,189,194,40,111,234,125,51,146,215,68,72,202,156,43,97,207,127,88,109,205,90,93,121,204
Data 89,87,127,220,84,85,133,211,84,93,122,200,88,79,115,193,116,70,94,177,164,64,73,160,214,61,60,138,207,126,54,95,161,210,79,49,135,199,148,77,76,136,210,159,38,91,170,192,141,58,107,136,197,143,41,83,146,209,145,64,80,142,186,199
Data 100,63,121,150,205,143,43,88,142,180,188,82,41,95,163,199,191,92,57,113,153,184,181,81,41,112,145,183,205,113,36,104,128,162,203,152,73,60,117,143,182,191,129,45,52,118,160,178,185,153,48,51,131,139,168,193,153,93,44,89,148,152,172,188
Data 140,73,48,100,144,161,171,191,160,88,41,78,136,159,155,183,182,149,69,43,93,139,153,155,183,178,163,88,36,81,114,155,158,155,179,172,146,76,43,50,121,155,159,164,160,170,169,142,78,38,52,103,151,166,159,157,160,166,160,140,83,38,55,82
Data 142,165,162,163,147,154,165,154,145,114,55,44,53,103,148,168,169,161,155,145,145,156,151,144,125,106,60,49,58,85,134,156,174,171,161,158,145,140,136,143,148,140,132,119,116,34,28,111,226,100,125,185,106,178,115,102,160,91,132,162,107,188,85,106
Data 102,96,186,91,163,121,92,179,86,150,130,92,163,88,155,126,92,153,87,174,104,146,124,92,194,87,180,92,98,100,95,198,79,201,79,126,144,121,152,88,192,88,195,83,112,81,113,151,87,147,90,201,82,204,82,144,112,97,101,100,177,86,157,89
Data 203,83,198,84,178,91,195,86,142,107,170,93,118,130,147,103,109,147,135,111,103,156,125,107,92,154,115,109,99,149,92,104,107,136,98,99,122,113,105,90,144,98,127,85,187,90,168,87,207,85,210,97,160,94,171,119,104,118,110,188,86,184,86,184
Data 88,179,89,106,120,101,124,96,203,84,207,87,126,106,111,114,86,200,85,205,101,118,113,86,201,83,203,103,106,121,97,204,86,174,92,97,164,90,205,98,120,114,100,161,88,163,97,115,199,85,197,93,101,174,90,209,108,106,163,90,147,106,104,157
Data 81,134,102,100,199,88,122,121,84,173,97,110,210,88,134,113,89,177,101,109,171,89,121,132,95,142,113,100,212,101,106,198,86,110,177,86,157,158,86,168,101,88,170,98,102,171,97,104,208,98,100,210,85,101,209,92,112,192,92,107,208,85,102,207
Data 87,110,179,95,104,205,116,95,169,105,87,134,135,91,117,197,83,121,203,92,105,203,121,92,143,128,84,118,204,82,103,172,106,99,153,189,82,119,209,106,99,147,126,78,112,203,84,88,129,162,84,106,171,107,94,124,210,86,108,130,189,83,117,144
Data 146,87,124,164,117,90,129,185,105,93,129,202,96,97,131,203,96,97,130,206,100,94,126,210,108,90,125,196,135,81,121,166,182,75,113,143,211,85,101,131,169,115,85,122,137,195,78,105,126,176,109,85,123,136,208,79,103,124,150,158,79,103,130,176
Data 116,76,112,135,193,152,77,116,137,159,142,77,114,129,156,155,73,101,132,144,192,87,91,127,140,205,126,72,112,131,137,194,70,98,122,137,168,131,69,102,133,140,162,148,73,114,130,140,172,135,72,99,131,141,143,201,70,96,122,139,140,193,153,67
Data 107,133,140,138,195,85,80,112,134,141,139,184,98,74,118,132,139,138,175,169,64,100,132,140,141,135,189,135,67,108,132,138,139,136,176,159,62,99,129,138,139,138,142,184,105,71,114,137,140,141,135,135,167,131,67,107,128,140,138,136,136,133,172,109
Data 65,98,129,140,140,138,134,134,132,167,116,65,94,130,137,134,132,129,128,127,133,159,132,64,99,123,140,141,137,138,134,130,129,129,134,163,117,65,90,128,140,141,139,136,133,133,129,130,127,127,127,144,156,119,63,94,130,141,143,131,120,121,123,130
Data 115,113,115,119,121,113,112,114,130,119,118,118,139,127,125,126,139,122,124,121,132,118,121,115,140,126,124,126,129,118,118,114,124,122,136,127,121,120,128,124,115,132,119,146,118,125,118,143,125,147,126,136,120,145,116,126,125,121,131,112,132,113,157,124
Data 145,121,141,132,133,122,119,130,126,121,115,162,111,129,157,116,99,141,114,93,156,134,124,119,166,105,113,167,126,113,138,161,105,124,157,110,115,147,154,100,112,153,97,122,135,155,95,136,154,112,108,138,159,101,105,153,144,121,111,166,141,96,120,148
Data 139,98,115,161,131,109,124,158,151,95,137,155,143,105,109,170,150,98,108,137,169,107,97,134,155,134,96,119,159,150,111,108,133,173,129,95,126,132,166,116,93,132,148,143,96,98,129,154,143,118,96,128,158,150,112,104,129,153,154,111,108,125,142,162
Data 124,111,104,126,168,134,102,103,119,147,158,131,98,109,124,150,158,121,100,109,132,158,159,128,101,111,125,155,158,129,113,98,122,146,152,151,115,96,115,136,144,154,139,111,92,119,137,142,159,141,100,99,105,132,145,148,150,128,91,96,127,136,143,153
Data 146,111,95,104,127,139,149,152,148,128,92,92,123,137,139,149,156,141,110,90,99,123,138,140,144,147,145,116,96,98,115,135,138,141,147,147,150,123,94,93,106,129,140,142,139,147,150,139,126,94,94,109,133,142,144,141,142,149,144,135,114,100,90,102
Data 130,138,144,143,137,136,138,139,136,127,110,91,93,103,124,142,145,145,142,136,135,136,140,138,128,125,108,96,94,105,120,137,147,149,145,142,137,133,132,133,136,135,130,126,123,93,77,99,157,122,145,121,124,143,119,135,131,117,141,113,126,141,120,141
Data 115,121,124,117,141,119,119,130,115,138,122,132,131,116,140,112,134,128,117,136,114,138,119,134,125,117,144,115,144,114,122,116,120,145,111,145,111,132,127,131,128,117,147,116,146,110,130,127,131,126,118,147,119,147,112,138,113,141,115,125,113,127,129,118
Data 123,120,143,114,138,116,148,113,146,113,144,114,148,113,140,116,146,114,137,118,126,113,134,115,122,111,130,116,124,112,135,116,128,113,139,115,134,114,146,114,140,115,150,114,148,118,143,116,148,125,127,123,131,135,115,133,116,149,114,149,113,148,117,137
Data 118,136,132,117,133,115,148,113,149,113,125,125,121,145,113,148,113,132,121,125,125,114,148,113,149,121,122,127,116,150,114,147,116,135,135,115,145,114,133,123,120,132,114,148,117,132,139,114,151,114,120,132,116,148,119,126,129,117,149,117,127,128,114,148
Data 114,123,144,111,144,118,115,150,113,136,124,115,151,117,124,151,115,137,125,115,149,118,121,153,115,127,131,114,135,126,116,143,122,118,149,119,119,146,113,119,143,113,135,142,113,136,125,116,135,125,114,152,126,115,150,120,115,145,122,117,137,125,115,149
Data 131,113,139,123,113,129,133,114,122,144,113,125,154,115,119,154,122,116,148,121,113,128,135,113,128,153,114,120,155,125,115,138,129,113,123,153,114,116,140,128,114,123,156,113,117,131,130,111,124,153,117,116,138,148,112,122,154,132,113,125,154,122,115,130
Data 144,112,117,136,134,112,120,143,128,113,122,146,125,113,122,147,125,113,121,145,126,112,121,139,131,111,118,133,141,110,116,128,153,111,113,127,156,119,111,123,139,134,110,117,129,155,113,112,124,142,131,110,117,129,157,127,110,123,134,156,115,114,126,133
Data 152,111,117,125,137,146,109,113,127,137,142,113,114,126,136,147,115,113,127,133,153,122,110,124,130,142,137,106,111,125,130,154,124,107,121,130,133,155,110,113,124,132,139,145,112,111,126,132,135,155,111,112,123,131,134,156,113,107,121,131,133,139,145,106
Data 114,124,131,132,151,137,105,116,128,132,133,147,127,105,113,127,132,132,135,148,107,106,122,131,133,132,140,139,104,109,124,131,132,131,136,145,105,111,122,131,132,132,131,145,128,104,112,126,132,133,132,131,141,136,109,109,124,132,133,133,131,130,137,142
Data 106,111,122,130,133,132,132,130,130,142,130,106,109,125,131,131,130,129,128,128,127,138,135,110,106,122,131,134,133,132,131,130,128,128,129,137,139,107,108,119,130,133,133,133,132,130,129,128,127,127,127,133,139,129,104,109,121,131,134,135,128,136,126,131
Data 126,133,124,127,125,130,122,125,123,127,124,125,123,126,125,127,123,128,125,127,124,128,124,125,128,125,125,127,126,130,124,126,125,127,123,128,125,134,124,129,126,131,125,133,126,132,126,131,127,128,127,128,130,124,126,126,131,125,131,122,130,127,135,126
Data 131,127,131,129,128,130,123,129,128,129,118,137,123,118,133,127,113,124,144,112,133,144,122,121,144,134,113,142,132,117,125,144,119,112,140,127,119,134,141,116,117,143,131,120,128,142,122,115,139,127,121,120,142,121,114,132,139,122,117,131,141,114,120,136
Data 136,116,118,140,135,116,118,134,142,113,124,136,139,118,116,130,143,117,116,125,143,124,112,123,137,135,113,113,134,143,121,114,121,144,134,118,120,128,146,135,112,124,136,143,131,112,122,137,144,125,111,124,140,142,123,114,120,137,145,125,115,117,133,147
Data 138,114,115,125,137,140,120,113,116,130,145,134,118,114,122,137,147,135,114,115,121,136,146,132,120,113,123,139,145,140,123,110,121,132,140,143,127,112,113,129,135,141,146,123,108,117,126,135,145,142,126,111,112,123,134,139,141,134,113,108,122,129,135,141
Data 140,130,110,112,124,132,137,141,141,130,114,106,120,131,134,138,143,138,128,111,109,121,129,136,137,139,141,130,113,108,113,126,133,136,136,140,140,128,116,106,112,125,134,136,135,138,139,138,129,111,107,109,124,134,138,136,134,138,137,136,128,114,106,108
Data 120,132,137,137,135,133,134,135,133,129,120,111,107,111,123,131,137,138,137,133,133,132,135,134,131,127,118,110,107,111,120,131,136,139,138,137,135,133,130,131,132,132,130,127,126,118,101,107,124,134,135,125,133,127,126,132,123,129,131,122,129,122,126,132
Data 121,132,124,124,133,122,132,126,124,130,122,131,126,130,130,122,132,121,131,128,123,130,121,132,124,131,126,124,134,123,133,121,127,122,126,132,121,131,121,131,125,125,125,125,134,120,134,120,131,124,131,124,126,133,127,132,122,134,123,134,121,130,121,132
Data 123,127,122,128,129,124,126,126,133,122,135,124,135,122,134,123,135,122,134,123,135,121,133,121,133,119,130,120,134,120,133,122,135,121,134,123,135,122,136,125,134,123,136,127,129,126,131,130,124,129,125,128,121,133,121,132,122,136,122,136,126,129,125,128
Data 132,121,132,122,135,122,135,127,125,127,124,135,122,136,122,129,126,126,127,121,135,121,136,122,126,127,123,130,121,136,122,133,130,122,133,121,133,125,127,129,122,137,123,134,131,122,135,122,129,128,122,132,123,132,126,125,137,122,134,125,122,136,122,134
Data 124,120,135,121,131,132,121,137,122,122,135,122,135,131,122,138,123,122,136,122,134,132,122,137,124,122,138,123,128,136,122,131,128,122,134,127,122,137,125,122,137,121,122,136,121,128,136,121,128,130,121,126,131,121,126,133,121,132,135,121,129,130,121,125
Data 133,121,123,136,121,126,138,122,123,137,125,121,139,124,122,133,129,121,134,135,121,125,135,123,122,139,123,121,132,130,121,124,139,122,123,135,129,121,131,138,122,124,141,129,119,127,133,121,121,137,126,120,124,139,122,123,130,134,121,124,136,129,121,127
Data 140,125,121,130,141,123,122,132,139,122,122,134,138,121,123,135,138,121,122,133,138,121,122,131,140,121,121,129,141,124,120,126,141,127,119,125,139,135,119,123,131,141,122,120,127,136,130,119,124,128,140,121,120,125,135,132,119,121,127,141,125,119,123,129
Data 141,127,119,124,131,140,125,119,125,131,141,124,119,125,129,141,125,118,123,129,139,130,119,121,128,134,142,122,117,124,127,136,130,117,119,127,130,142,130,117,123,129,131,142,124,118,125,129,131,142,123,117,123,129,131,137,133,117,122,126,130,133,139,124
Data 116,124,129,130,134,136,117,117,124,129,131,133,139,118,118,123,128,130,131,139,126,116,122,129,130,131,133,136,122,116,123,129,130,130,131,138,125,115,122,128,130,130,130,135,137,118,117,125,129,130,130,130,131,138,121,116,121,128,130,131,130,129,132,137
Data 119,115,122,128,130,131,130,129,129,132,137,119,116,121,128,130,129,129,128,128,127,129,136,122,115,119,127,131,131,130,130,129,128,128,128,132,135,120,114,120,128,131,131,131,130,129,129,128,128,127,127,128,133,131,121,114,121,128,130,136,129,131,127,129
Data 127,130,127,129,126,129,127,129,126,128,126,129,126,127,126,128,126,128,126,129,126,128,126,129,125,127,126,128,126,129,126,130,126,128,127,128,126,130,127,129,127,129,128,127,127,129,128,126,128,127,127,126,129,126,128,126,129,127,129,127,130,128,130,128
Data 127,128,128,128,126,129,126,127,126,128,123,125,130,122,129,133,124,124,136,125,122,135,127,124,130,133,121,132,135,124,125,135,129,120,132,130,123,124,134,124,121,133,132,123,123,134,127,120,128,134,124,123,130,133,121,127,134,129,122,127,137,127,123,130
Data 133,128,122,131,133,125,122,129,136,126,120,130,135,128,121,126,136,129,122,125,134,135,122,123,131,135,126,119,128,135,130,122,123,128,137,125,122,125,134,134,121,123,127,135,132,120,120,131,137,129,121,121,132,136,132,122,122,130,137,133,122,121,126,136
Data 135,123,121,122,130,135,131,120,120,127,134,136,125,120,121,129,137,134,122,119,122,131,137,136,125,119,123,128,135,136,127,119,120,128,134,137,134,121,118,123,129,134,138,132,120,120,125,129,135,137,129,121,116,123,129,132,136,133,122,116,119,127,131,134
Data 136,131,120,118,121,127,132,135,136,133,122,116,118,126,131,133,135,136,130,120,116,119,127,132,132,134,136,131,125,116,118,125,130,133,133,134,135,132,123,116,117,122,129,132,132,133,134,134,130,123,116,116,123,128,133,133,132,133,134,133,129,124,117,115
Data 121,127,132,133,132,131,131,132,131,129,126,119,115,117,121,128,133,134,133,132,131,130,131,131,130,128,125,119,116,117,119,126,131,134,134,133,132,131,130,129,130,130,130,128,127,124,117,112,122,131,131,129,130,127,127,128,126,129,128,128,129,125,127,126
Data 126,129,125,129,127,126,129,125,129,127,126,128,125,129,127,128,128,125,129,125,129,127,125,128,125,129,126,127,127,126,130,124,130,125,128,128,127,129,125,130,125,129,126,127,126,127,129,125,129,125,129,125,130,125,128,128,128,128,126,130,126,130,125,130
Data 125,130,125,129,127,129,126,128,129,128,127,127,130,128,129,126,130,127,129,126,131,127,130,125,129,126,129,125,130,126,129,126,130,127,129,126,130,128,128,127,129,127,126,129,127,128,125,130,125,129,125,131,125,130,126,130,126,127,128,127,128,125,130,125
Data 130,125,130,126,130,128,126,128,125,130,125,130,125,131,127,127,128,126,130,125,131,125,127,128,126,129,125,131,125,130,128,125,130,125,130,126,128,127,125,131,125,131,128,125,130,125,130,127,127,129,125,131,126,128,128,125,132,126,129,130,125,131,126,125
Data 130,124,130,127,124,130,124,127,128,124,131,127,126,130,125,128,129,125,132,127,126,131,125,127,129,125,132,126,125,132,126,128,132,125,129,129,125,130,128,124,130,128,124,132,127,124,132,125,124,132,125,126,132,125,125,131,126,125,132,125,125,132,125,125
Data 132,126,125,132,125,124,132,126,124,130,128,124,131,130,124,128,130,125,125,132,125,124,132,127,124,129,130,124,128,133,125,125,133,128,124,130,130,125,125,133,126,124,129,130,124,126,132,126,123,130,131,124,125,133,129,124,127,132,126,124,130,130,125,125
Data 133,128,124,125,134,127,124,126,134,126,124,126,133,125,124,127,134,125,124,126,133,125,124,126,134,126,123,125,133,127,123,125,131,130,123,124,129,133,124,123,126,134,127,123,125,131,131,125,124,127,134,129,123,125,130,134,125,123,126,133,132,124,124,128
Data 133,130,123,125,127,134,128,123,124,128,134,128,123,124,127,134,132,123,124,128,130,134,125,123,126,129,135,127,122,123,127,131,134,124,122,126,129,132,131,123,124,126,129,135,128,123,124,127,129,133,131,123,124,126,129,132,132,125,122,126,128,129,134,128
Data 122,123,127,129,131,134,126,121,125,127,129,130,134,124,121,124,127,129,129,133,129,121,122,126,129,129,129,134,127,121,123,127,129,129,129,133,128,121,122,126,128,129,129,130,133,124,121,123,127,129,129,129,129,133,126,122,123,127,129,129,129,129,130,132
Data 128,121,123,126,129,129,129,129,129,130,133,128,121,123,127,128,129,128,128,128,128,128,132,129,121,122,126,129,129,129,129,129,128,128,128,129,132,128,121,122,125,129,130,130,129,129,128,128,128,128,127,128,129,131,126,120,121,126,129,132,130,128,128,128
Data 128,127,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,127,127,128,127,128,127,128,127,127,128,128,127,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,128,128,127,128,128,127,128
Data 127,129,127,128,127,128,128,127,127,127,127,126,129,126,126,130,127,125,129,128,124,130,130,126,128,131,127,126,131,127,125,129,129,124,126,131,126,125,129,130,124,129,131,126,125,130,130,124,126,131,128,125,128,131,125,124,130,129,125,125,131,129,125,126
Data 130,129,124,125,131,128,124,126,131,129,124,126,131,129,124,124,131,130,125,124,128,132,126,123,127,131,128,124,125,131,130,125,124,127,133,128,124,125,130,132,128,123,126,131,132,126,123,128,131,131,125,124,126,132,131,125,124,126,132,132,127,124,126,131
Data 133,129,124,124,126,132,130,124,123,125,130,133,128,124,123,127,132,133,128,123,124,127,131,133,128,124,124,127,131,133,130,124,123,125,129,132,132,128,123,124,128,130,132,131,125,122,124,128,131,133,131,125,121,124,126,130,132,131,128,122,122,126,128,130
Data 133,131,127,122,123,127,129,131,132,131,128,122,121,126,128,130,132,132,131,126,122,122,126,128,130,131,132,132,127,122,121,123,127,130,130,131,132,131,126,123,121,123,127,129,130,130,131,132,130,126,121,120,122,127,130,131,130,130,131,131,130,126,122,120
Data 121,126,129,131,131,130,130,130,130,129,127,124,121,120,123,127,129,131,131,131,130,129,130,130,130,128,127,123,122,121,122,126,128,131,132,131,131,130,129,129,129,129,129,128,127,127,122,119,123,128,128,129,129,128,129,128,127,128,127,128,128,127,128,126
Data 127,127,127,128,127,128,127,127,128,126,128,127,127,128,127,128,127,127,128,127,128,127,128,127,127,128,127,128,127,127,127,127,128,126,128,126,128,128,128,128,127,128,127,128,126,128,126,128,128,127,128,127,128,126,128,126,128,127,127,127,127,128,127,128
Data 127,128,126,128,126,128,127,129,127,128,127,128,127,128,128,128,127,128,128,128,127,128,128,128,127,127,127,127,127,127,128,127,127,128,128,127,127,128,127,128,127,128,127,128,127,129,127,128,127,129,127,128,127,128,127,127,128,127,128,127,129,127,128,127
Data 128,127,128,127,127,128,127,128,126,128,127,128,128,127,128,127,129,127,128,127,127,128,127,128,127,128,127,128,128,127,128,126,128,127,128,127,126,129,127,129,128,127,128,127,129,127,128,128,127,129,127,128,127,127,129,127,129,128,127,129,127,128,128,127
Data 128,127,127,128,126,128,127,127,128,127,128,128,127,129,127,127,128,127,128,128,127,129,127,127,128,127,127,128,127,129,128,127,129,127,127,129,127,128,129,127,128,128,127,128,128,126,128,128,126,129,128,126,129,127,126,129,128,127,129,128,127,129,127,126
Data 128,127,126,128,128,126,128,128,127,128,128,127,127,129,127,127,129,127,127,128,128,127,128,128,127,127,128,127,127,129,127,127,128,128,127,128,129,127,127,129,128,127,128,129,127,126,128,127,126,127,129,127,126,128,128,127,127,129,128,127,127,129,127,127
Data 128,129,127,127,128,128,127,127,128,128,127,127,129,128,127,127,129,128,127,127,129,128,127,127,129,128,127,127,128,129,127,127,128,129,127,127,127,129,128,127,127,128,128,127,127,127,129,127,127,127,128,128,127,127,127,129,127,127,127,128,129,127,127,127
Data 128,128,127,127,127,129,129,127,127,127,128,128,127,127,127,128,129,127,127,127,128,129,128,127,127,128,129,128,127,127,127,128,129,127,127,127,127,128,128,127,127,127,128,128,128,127,127,127,128,128,128,127,127,127,128,128,129,127,127,127,127,128,128,128
Data 127,127,127,128,128,128,128,127,127,127,128,128,128,128,127,127,127,128,128,128,128,127,127,127,127,128,128,128,128,127,127,127,128,128,128,128,128,127,127,127,127,128,128,128,128,128,127,127,127,128,128,128,128,128,128,127,127,127,128,128,128,128,128,128
Data 128,127,127,127,128,128,128,128,128,128,128,128,127,127,127,128,128,128,128,128,128,128,128,128,127,127,127,127,128,128,128,128,128,128,128,128,128,128,127,127,127,128,128,128,128,128,128,128,128,128,127,128,128,128,128,127,127,127,128,128,128,128,128,127
Data 128,127,128,128,128,128,128,128,128,0

.makeSound
	Restore shoot
	Read ln
	pos=0

	Repeat
		fileName$="C:\sound"+Rnd(1,1000)+".wav"
	Until FileType(fileName)=0

	fileOut=WriteFile(fileName)
		For pos=0 To ln-1
			Read bt
			WriteByte fileOut,bt
		Next
	CloseFile fileOut

	Global shootSound=LoadSound(fileName)
	DeleteFile fileName
Return


how did you design that sound????

Search for the label .makeSound in the code and you'll see it.

All i've done is taken a .wav file and stored it in Data statements, infact I wrote a seperate program to automatically create the Data xxx,xxx... code for me.

I then recreate the sound file in runtime, load it, then remove the file again.

There's probably a better way of doing this by storing the memory section of a loaded .wav file but I couldn't figure out how to do that.

Storing things in banks perhaps? I'm very new to Blitz but a skim of the manual and example code leaves me thinking you can read a datafile into a bank (and therefore can be saved back out again).

Wouldn't be the work of a few minutes to create a little tool that loads all of your datafiles into 1 bank (with some indexing at the end) and then you can save it out as one .dat (or whatever) file.

Not quite as nice as being able to just ditribute one .bb file, but it would scale up to large datasets quite well.

Basically yes you can assemble stuff in memory in Blitz relatively easily and construct images and meshes and all sorts from raw data, sound is a bit harder to do than images for reasons I forget now - that's why in the above example I used the data to write a .wav file, loaded it in, then deleted the .wav file - which is a slightly different method.

You can compile your media into your .exe's in this way but unfortunately it will inflate their filesize. There's even tools to do this already in the code archives somewhere. I feel it is better to keep media files seperate so that they can be compressed. Again there are tools which allow you to do this.

If you want to protect your media then the only real solution is to go proprietry, or to swap a few bytes around on your media files that you swap at load time.

Let's face it, most commercially available games have only a moderate amount of protection against ripping their model files, textures, bitmaps, movies and sounds.

If someone really wants a sound from your game, they will get it. For even a leyman hacker, the task will not be impossible. Byte-swapping is fine, until someone just dumps a raw file of the memory areas your task is using - after your game has just 'decrypted' all your resource files.

Where are we with this project?

Would love to help.

Hello.

The project is as you see it. If there's anything you want to add, feel free. I've not been able to spend much time on Blitz recently but intend getting back to it very soon. Feel free to collate everything and throw it into a codebox and I'll update the first post. It's nice to see that people are still interested in this. I've got a couple of other projects like this that I'm going to put up in the next couple of weeks - centipede, minesweeper and so on.

By the way, Yeshu, if you're interested in having a laugh I'm in a play called 'Ancient Lights' in the Dolman Theatre, Newport from the 14th November. If you're able to come and see it, it's a right cracker of a play with alcohol, dope-smoking, coke-snorting, bestiality, necrophilia, incest, underage sex and so on. Really, it's top.

Goodbye,

Jes

2 days away! should check this forum more often.

I'll try and come along, work and life permitting - how long does it run for?

Hello.

It runs from the 14th to the 19th, the play starts at 7.15 (7.30 Friday) and I think it's £8 or £5 with concessions.

Hope you can make it.

Goodbye,

Jes

Will do my best.

My band are looking to play a few venues in Newport, could you suggest any pubs worth approaching.

Bear in mind we play songs from the following bands:

Franz Ferdinand
Hives
Strokes
White Stripes

www.tunakings.tk if you want to see more.

Hopefully see you sometime this week, who do you play?

Hello.

Yeshu, the places you want to approach are:

TJ's - very popular amongst younger people. Lots of comparitively big name bands have played here - Dead Kennedys, Wildhearts, Butthole Surfers, Corrosion of Conformity, etc;
Le Pup - Probably your best bet. Lots of indie bands play here and Sam, the manager, though she can be a bit acerbic at times is very welcoming. They regularly have bands on;
The Riverside - Not as popular as the two places above but still have a good live music reputation;
The Hornblower - More a bikers venue but well renowned for live music and a good crowd. Don't think they'd have any concern with your choice of music.

I play Tom Cavellero, an American movie star who is just past his sell by date. But, boy, what fun he is :o)

Hope the above helps and hope you can make it to the show.

Goodbye.

Jes

Hi Jes,

Will try and get there tomorrow - playing in Tylerstown Saturday night so thats out.

Thanks for the list of venues, I'll pass it on to our organisor and see if we can get some dates sorted.

Where can I download the source for this project?

Hello.

Ok, Yeshu, I've updated the code in the first post to include Becky's sound code. All you need to do is copy and paste and compile - that's kinda the idea of this. Ok, so with the inclusion of becky's code there is a media file created, but as it's part of the code I think we can live with that.

Hope to see you tonight.

Later,

Jes

SoggyP: Break a leg and remember not to mention "The Scottish Play"! :)

Can I just say that this is a very, very hard version of Invaders!

I am very impressed with how fast the rendering is of the in-built shapes and I love the sound hack!

Whoever did the 2D version - you are my hero! Your game with no graphics looks 100 times better than mine with graphics!

If this topic isn't being used any more, can you God-like moderators that watch over all with that invisible presence of yours make this un-sticky to clear up the boards?

Thanks for being there like the air. (Hey! A rhyme!)

This topic is still being used. I have not programed for a while and one day desided to get back into it and desided to work on this. I will be posting what I have done soon.
Hold on a little longer.

OK. I was going to clean up this code a bit, but decided to post what I have for now. I also want to express some new ideas I have for this game. I have made lot's of changes that might seem odd for a spaceInvaders game. These changes are the basic consepts of the new game play I have in mind. Anyhow, I tried to keep the new functions as portable as posable so they can be used for other games. In fact I bult the Turret and turret select system seperate and then integraded it in. 5 fuction calls make up the Turret secondary bullets that fire anywhere the mouse imige is located, and these functions apear 1 after another in the main game loop like so.
 ;LaunchBullet(Player_Turret\x,Player_Turret\y,Player_Turret\iDir)
If KeyHit(46) = True Then ;this goes in dokeys

	For Player_Turret.PTurret_type = Each PTurret_type
		;For i = 1 To 16
	 		LaunchBullet(Player_Turret\x,Player_Turret\y,Player_Turret\iDir,Player_Turret\selected)
		;Next 
	Next 
End If



picked = get_picked(picked);Get keyboard and mouse input and asign picked accordingly

mousepointer=pick_pointer(picked);

Pick_A_Turret(picked)

UpdateBullets()


They should stay in that order but can be redistributed through out the main loop. (for example the mouseimage is drawn under the alian ships but needs to be drawn over it. Thats just more work that I was planning to do before posting the code.)

The comments are not all current I need to go through that too, but at the begining I have made coments about ideas I have for the gameplay. Not all will be done of course they are just Ideas. Like the Idea I have for the story line. In short you start out playing space invaders, then you get a mission and the game turns into a scrolling game kind of like zaxon but with mouse control. The goal is to reach the alian warp gates, travel through and destroy them from the other side, amd defeat the alian bosses. So there is three different game plays. Also you get itoms and have an iventory of weopons to use depending on the kind of alians you are fighting. Any how this is what I have done.
Made new enemy ship images, new bullet images, new bullet animations, a turret, a turret select system, the ufo at the top now appears at more random times and will come from iether side of the screen via a 16 image rotation function that will allow it to dive bomb the player, we can now shoot animating bullets, put in some game timeing, added mouse control, added a turret selection system that gives a inventory of turrets that have there own image,mousetarget, and soon will behave different acording to the selected turret. I have done lots of other things too.

There are new controls, Use the mouse right and left buttons to move, the mouse scroll button or numbers 1-3 to equip a different turret. Press c to fire a turret bullet. (Part of the behavior of the bullet I was talking about was different fireing rates, so time limiting has not bin implemented in the turret code yet.) Note: You might need to adjust the frametimer (right before main) to get a suitable frame rate for your computer. If it is still to fast you can slow it down in game useing - or + keys.

It's rather long now so I have to seperate it into chunks small enough to post. Just cut and paste in the same order they apear.

 
;My new contributions include the following
;all my changes will be highlighted with a ***
;all my aditions will be highlited with +++

;goals
;Mission objective; Get to enemies dimensions and destroy the worp gates so the invaders can not use it to 
; atack our world!
;1 make dragon come at random times,speeds,and direction 
;	a. Give dragon a variety of firepower
;		Ideas for fire power
;		I. eggs (if player shoots an egg before it lands let it turn into a minni dive bombing dragon)
;		(but if egg lands or hits a base shield it explodes with damaging particles) 

;2 make new and more interesting level changes
; Create a variable system for leval control involving 3 game play types
;	1. Fight basic enemy fighter in various attack patterns (standard space invaders)
;	2. Fight mixed enemy fighters and introduce new bombers.
;	3. Fight the mother ships with rotating turrits, or squads of dragon fighters
;	4. A leval the player is deep in a canyon and enemies are droping globbs of toxic waste
; that build up on walls and basses and puddle up on the floor! 
; limiting player movement by causing a constaint dripp 
;  note ( should make sure to introduce site to point transporter first or durring this leval )
; not all ufo's are bad a secondary wepon selection for a radio transmitter to contact a passing fleet ship
; to dropp bonesses. destroy them and get nothing or get penilized by the fleet abandining you, or it
; crashing and burning limiting player movement
;at the end of each leval a drop ship appears like the ufo and drops a new wepen or shield generator or 
;an item needed for future levals.
;3 invent boss enemies to fight every 3 levels

;4 make new boneses
;	bones Ideas as they come to me
;	a. different missles for closter fock
;	new ways to get bonesses
; 	bonesses that last until the game is over
;	New permanent until destroid ship add on's that add more fire power special abilities (telaport)
;		special abilities (Telaport,Machine Gun Fire (MGF),Deflectors,ClusterFock,Missles,,
;			player ship firepower crystals (PSFC) Damage Types
;note: PSFC's will each have individual properties: images,damagepower,effects,explosion animation,
;			 	ColdFusionReacter, a device that emits a gravitational orbit around the players ship, that 
;					collects particals and that protect the player from damage
;				ColdFusionPhoton, a cold attack that freezes a ships hull causing it's hull to expand
;					in a icy blue ring of distruction 
;				SolarNucleus, a fire attack That harnesses the power of the stars
;				BigBang, a force attack, moves all particles on screen away from it,and blows ships around it 
;					off the screen.	
;				DarkMatterQuazar, causes groups of ships to fold in on themselves
;				cosmic tryangle, 
;				PhotonStar, causes and explotion that fires multiple random damageing particles 
;				BlackDwarf, a gravitational force pulls in astroids and particles to its center 
;					objects that reach the center shrink out of existance BlackDwarf then fades out
;				whitedwarf, a gravitational force that pulls objects and particals in and then explodes 
;					again 


;5 change the way player is killed to include a life bar 
;	as ship is damaged downgrade its perfomance (speed, firerate, control responce)
;	show the damage by making a damage array, loose a rocket hear, a wing there


;6 create a few fire efects to be used for various puposes

;7 Make new kinds of bullets that do something other go up or down
;		a; a breakout type of bullet that bounses off sheilds or the player ship until it goes off screen
;		b; napon bombs that burst into flames limiting player movement
;		C; MOUSE GUIDED BULLETS
;		d: ai for a smart turret 		
;8 Give bases a biger roll in combat by adding fire power via mouse control.	
;       BaseCharge,Base Self Destruct(BFD),mouse guided missles,ttack
;9 PLAYER CHANGES
;	1. A group of fighters circle the player acting as a shield 
;		a. When secondary wepon's call air strike selection is on hovered over an enemy enemy gets targeted
;		b. fighters folow mouse and shoot at it (in its direction) at will.
;		c. wing men that stay side by side with the player




Gosub makeSound
 TFormFilter 1

Global funct_used

Type Control_Type
	Field Max_Bombs
	Field Bomb_Speed
	Field Crit_Drop_Speed
	Field drop_bomb_chance
	Field Player_StartSpeed
	Field Player_Speed
	;Field Player_index
	Field Bullet_Speed
	Field Max_Rows
	Field Max_Cols
	Field XRes, YRes, Depth
	Field Beast_Speed#
	Field Beast_Speed_Increment#
	Field UFO_Speed
	;+++  direction and index# 
	Field UFO_dir
	Field ufo_index ;index# a referance number in the array that determins what kind of ship to draw
	Field Level
	Field NextExtraLife
End Type

Type points_type
	Field x,y
	Field id
End Type

Type explosion_type
	Field x,y
	Field speed
	Field status
	Field dirx,diry
	Field count
	Field id
End Type

Type HighScoreTable_Type
	Field score
	Field name$
End Type

Dim HighScores.HighScoreTable_type(10)
Global highscore.highscoretable_type
Dim SpaceyFont(40)

Type Player_Type
	Field x,y
	Field moved
	Field lives
	Field score
	Field Shield_Active
	Field Shield_Timer#
	Field Non_Expiring_Shot
	Field NES_Timer# ; Non-expiring shot timer
	Field Cluster
	Field Cluster_Timer#
	Field Speedy
	Field Speedy_Timer#
End Type

Type stars_type
	Field image
	Field x,y
	Field count
End Type

Type Beast_Type
	Field x#,y#
	Field deleted
End Type

Type Bullet_Type
	Field fired
	Field x,y
	Field frame ;+++ keep track of each frame of each animating bullet 
End Type



Type Bomb_Type
	Field fired
	Field x,y
	Field frame	;+++
	Field deleted 
End Type

Type UFO_Type
	Field x,y
	Field status
	
	
	
	
End Type

Type Bonus_Type
	Field active
	Field x,y
	Field frame
	Field frametimer#
End Type
Function Make_lazorcannon_im(lazor_cannon_im)
	SetBuffer ImageBuffer(lazor_cannon_im)
		midx=ImageWidth(lazor_cannon_im)/2
		midy=ImageHeight(lazor_cannon_im)/2
		Color 255,0,0
		Rect midx-10,midy-10,20,20,0	
End Function
;pulsar_cannon_im = CreateImage(20,20)
;Make_pulsarcannon_im(pulsar_cannon_im)
Function Make_pulsarcannon_im(pulsar_cannon_im)
	SetBuffer ImageBuffer(pulsar_cannon_im)
		midx=ImageWidth(pulsar_cannon_im)/2
		midy=ImageHeight(pulsar_cannon_im)/2
		Color 255,255,0
		Rect midx-10,midy-10,20,20,0
End Function
;photon_cannon_im = CreateImage(20,20)
;Make_photoncannon_im(lazor_cannon_im)
Function Make_photoncannon_im(photon_cannon_im)
	SetBuffer ImageBuffer(photon_cannon_im)
		midx=ImageWidth(photon_cannon_im)/2
		midy=ImageHeight(photon_cannon_im)/2
		Color 255,255,255
		Rect midx-10,midy-10,20,20,0
End Function
 









;end of turret set up ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

;*********************************
; Create and Set up Control Type
; This is used to manage all our game control variables,
; it's easier keeping them in one place and putting the set up at the start means we can 
; control the details in the rest of the set up from here on in

Global control.Control_Type
Set_Up_Control

; Set graphics size
Graphics control\xres,control\yres,control\depth
AutoMidHandle True

Dim im(15)
Dim im2(15);IM2____________________IM2_______________________________________________

Dim bases(3)
Dim Points_Ims(16)
Dim debri(16)
Dim stars.stars_type(3)
;+++

;+++ 
Const rots = 16 ;+++ number of rotations for generic rotation function
;Const image_index = 2 ; how many space ships will be able to rotate in the game,ship_type 
;Global image_index

Dim rot_im_array(rots);+++ Dimention the image rotation array
 



Function Make_image_rotate(bitmap)
;the bitmap variable is for any specified image in the function call

	For frame = 0 To rots - 1 
		rot_im_array(frame) = CopyImage(bitmap)
		RotateImage rot_im_array(frame), frame * 360/rots
		DebugLog "rotations "+ frame * 360/rots

		
	Next 
End Function 

; Mouse code starts++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;
;makepoint(mousepoint)
;make the imiges to be used for the hud
mouseimage=CreateImage(20,20)
makemouse(mouseimage)

mousepoint=CreateImage(1,1)
makepoint(mousepoint)
	
Global targetimage=CreateImage(20,20)
maketarget(targetimage)

Global blankimage=CreateImage(23,23)
blanktarget(blankimage)
 
 
Global targetpointimage1=CreateImage(23,23)
maketargetpoint1(targetpointimage1)

Global targetpointimage2=CreateImage(23,23)
maketargetpoint2(targetpointimage2)

Global targetpointimage3=CreateImage(23,23)
maketargetpoint3(targetpointimage3)

Global targetpointimage4=CreateImage(23,23)
maketargetpoint4(targetpointimage4)

Global targetpointimage5=CreateImage(23,23)
maketargetpoint5(targetpointimage5)




 

Global gorightimage=CreateImage(20,20)
goright_im(gorightimage)

Global goleftimage=CreateImage(20,20)
goleft_im(goleftimage)

Global idoltargetimage=CreateImage(20,20)
makeidoltarget(idoltargetimage)



Global player_point=CreateImage(20,20)
SetBuffer ImageBuffer(player_point)
	
	Color 0,0,250
	Line 10,1,1,20
	
	Color 0,0,250
	Line 10,1,20,20
	

	Color 200,0,0
	Line 1,19,20,19


Function makepoint(mousepoint)
	SetBuffer ImageBuffer(mousepoint)
	Color 0,255,0
	Plot 0,0
End Function

Function maketargetpoint1(targetpointimage1)
SetBuffer ImageBuffer(targetpointimage1)
	 	Color 0,55,5
		Oval -1,-1,25,25,False
	
		Color 0,105,5
		Oval -2,-2,27,27,False
	
		Color 0,155,5
		Oval -3,-3,29,29,False
	
		Color 0,205,5
		Oval -4,-4,31,31,False
	
		Color 0,255,5
		Plot 0,0
		Plot 22,0
		Plot 0,22
		Plot 22,22
End Function  		
Function maketargetpoint2(targetpointimage2)
SetBuffer ImageBuffer(targetpointimage2)
		Color 180,180,0
		Oval -1,-1,25,25,False
	
		Color 200,200,10
		Oval -4,-4,31,31,False
	
		Color 255,255,10
		Plot 0,0
		Plot 22,0
		Plot 0,22
		Plot 22,22
	
		Plot 12,12
		Plot 10,10
		Plot 12,10
		Plot 10,12
	
		Color 20,205,10

		Plot 11,11		
End Function 
Function maketargetpoint3(targetpointimage3)
SetBuffer ImageBuffer(targetpointimage3)		
		Color 255,25,225
		Oval -1,-1,25,25,False
	
		Color 240,20,225
		Oval -2,-2,27,27,False
	
		Color 200,25,225
		Oval -3,-3,29,29,False
	
		Color 160,10,225
		Oval -4,-4,31,31,False
	
		Color 120,5,225
		Plot 0,0
		Plot 22,0
		Plot 0,22
		Plot 22,22	    
End Function
Function maketargetpoint4(targetpointimage4)
SetBuffer ImageBuffer(targetpointimage4)		
		Color 255,255,225
		Oval -1,-1,25,25,False
	
		Color 240,205,225
		Oval -2,-2,27,27,False
	
		Color 200,255,225
		Oval -3,-3,29,29,False
	
		Color 160,105,225
		Oval -4,-4,31,31,False
	
		Color 120,55,225
		Plot 0,0
		Plot 22,0
		Plot 0,22
		Plot 22,22	    
End Function 
Function maketargetpoint5(targetpointimage5)
SetBuffer ImageBuffer(targetpointimage5)		
		Color 0,255,225 ;top left blue
		
		Line 0,0,12,12
		
		;Color 0,255,0;top right green

		
		Line 23,0,11,11
		
		;Color 255,0,0;bottomright red

		
		Line 23,23,12,12
		
		;Color 255,0,225 ;bottom left purple

		
		Line 0,23,11,11

		;Color 255,0,225
		;Rect 0, 0, 23, 23,0
		;Rect 12,12,4,4,0
		;Rect 8,8,4,4,0
		;Rect 8,12,4,4,0
		;Rect 12,8,4,4,0
		Color 0,0,0

		Rect 7,7,9,9,1
		

		;Color 255,55,25

		Rect 5,5,13,13,0
		;Rect 4,4,10,10,0
		Rect 2,2,19,19,0

		
	
		Color 255,55,0
		Plot 0,0
		Plot 22,0
		Plot 0,22
		Plot 22,22
		
		

		HandleImage targetpointimage5, ImageWidth(targetpointimage5)/2,ImageHeight(targetpointimage5)/2
		;RotateImage targetpointimage5,45
		;Rect 0, 0, 10, 10,0 	    
End Function 

 

Function makemouse(mouseimage)
	SetBuffer ImageBuffer(mouseimage)
	Color 100,60,250
	Line 0,0,20,10
	Line 0,0,10,20
	Line 20,10,10,20
	
End Function

Function maketarget(targetimage)
	SetBuffer ImageBuffer(targetimage)
	Color 255,20,20
	Line 0,10,20,10
	Line 10,0,10,20

	;Line 0,10,10,20
	;Line 20,110,10,20
	
End Function

Function makeidoltarget(idoltargetimage)
	SetBuffer ImageBuffer(idoltargetimage)
	Color 100,5,50
	Line 5,10,15,10
	Line 10,5,10,15

	;Line 0,10,10,20
	;Line 20,110,10,20
	
End Function

Function blanktarget(blankimage)
	SetBuffer ImageBuffer(blankimage)
	Color 0,0,0
	Rect 0,0,23,23,1
	Color 255,0,0

	Plot 11,11
	;Line 5,10,15,10
	;Line 10,5,10,15

	;Line 0,10,10,20
	;Line 20,110,10,20
	
End Function



Function goleft_im(goleftimage)
	SetBuffer ImageBuffer(goleftimage)
	
	For l=0 To 5
	
		Color 45*l,20*l,255-40*l
		Line 20,10,5+2*l,0+l+l
	
		Line 20,10,5+2*l,19-l-l
	Next 


End Function 

Function goright_im(gorightimage)
SetBuffer ImageBuffer(gorightimage)
	
	
	For l=0 To 5
	Color 45*l,20*l,255-40*l

	
		Line 0,10,15-2*l,0+l+l
	
		Line 0,10,15-2*l,19-l-l
	Next 

End Function
 
;Function drawimages(mouseimage,mousepoint)
Function update_target_point(mouseimage,mousepoint)
	DrawImage mouseimage,MouseX(),MouseY()
	DrawImage mousepoint,MouseX(),MouseY()
End Function

; Mouse code ends++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Global zspeed
Global bim 
Global ufo_im
Global ship_im 
Global bonus_im
Global base_Im

Global bomb_im = CreateImage(20,20,16);BOMB ;BOMB ;BOMB ;BOMB ;BOMB ;BOMB ;BOMB ;BOMB ;BOMB ;BOMB ;BOMB \
Global bomb_im1 = CreateImage(6,24)

Global xp,yp
Global blank_im = CreateImage(6,24)
Global point.points_Type
;bullet code BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
Global bullet_im = CreateImage(6,24)
MidHandle bullet_im
;Global rappedfire_im = CreateImage(6,24,4)
Global rappedfire_im ,rtimer#
Global rframe

rappedfire_im = CreateImage(6,24,16)
Make_rappedfire;+++


Global Quazar_im = CreateImage(20,20,16)

;bullet code ends BBBBBBBBBBBBBBBBBBBBBEEEEEEEEEEEEEBBBBBBBBBBBBBBBEEEEEEEEEEEEEBBBBBBBBBBBBBBBBEEEEEEEE
Global dir# = control\beast_speed
Global score = 0
Global beast_count, total_beasts
Global x#, y#
Global EndGame = False
Global char$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 @#~"
Global adjusttimer = 0
;Global set_master_time$
Global set_master_time

;set_master_time$ = Input ("Master time = ") 
;Write set_master_time$
;set_master_time$=Input$("Please enter a desired frame rate: ") 
;Write "Frame rate set to," + set_master_time$ + "!" 

;set_master_time = (set_master_time$)
set_master_time = 40 
Delay 100

Global frameTimer=CreateTimer(set_master_time); +++ Game timer , Slow it down! 
;Global s

Global explosion.Explosion_type
Global player.Player_Type
Global beast.Beast_Type
Global bullet.bullet_type
Global bombs.bomb_type
Global ufo.ufo_type = New ufo_type
Global Bonus.Bonus_type = New Bonus_type
player.Player_Type = New Player_Type	; create player

Make_Base_Image
Make_Bonus_Images
Make_Collision_Image
Make_Player_Image
Make_Beast_Images
Make_Beast_Images_2 ; +++ a new beast ship for leval two and 3
Make_Beasts
Make_Bases
Make_Points_Ims
Make_Blank

Make_Bombs
Make_Bombs1

Make_Bullets_im
Make_Quazar;+++






;Make_rappedfire;+++
;Make_rappedfire;+++

Make_Debri
Make_Stars
Make_Ship
Make_Ufo_im
Make_Player

Make_Bullet
Make_HighScoreTable
Make_SpaceyFont
;Make_image_rotate(ship_im)
Make_image_rotate(ufo_im)



;*****************************************************************************************************
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Type TBullet
    Field iDir                 ;Holds the direction the Bullet is moving
	Field dX#,dY#              ;Holds the screen x,y coordinates of the bullet
	Field dDistance            ;Holds the counter to see if a bullet has run it's course
	Field dSpeedX#, dSpeedY#   ;Holds the current speed for x and for y
	Field dSpeedModifier#      ;Holds the added speed of the bullet to the current speed
	Field collided			   ;If the bullet collides with an enemy this is set to 1 and that bullet type will be destroyed
	Field frame
	Field equiped
	Field selected 
End Type

Type PTurret_type ;+++
	Field x,y  ;global location on screen to draw the turret relative to the playership image
	Field width ;width in pixels or screen proportions, size of the turret image
	Field height;height in pixels or screen proportions, size of the turret image
	Field frame
	Field ammo ; type of bullet the turret shoots 
	Field equiped
	Field iDir 
	Field selected ;The currently selected turret wepon selection.  
End Type

;Constants INITIALIZE TURRETS___________________________________________________________________________
Const Turret_Rotations = 360
Const Total_num_turrets = 3 
Const numrotations=360
Const total_num_lazors = 3
Const SpaceBar=57 

Dim Turret_array_im(Total_num_turrets,Turret_Rotations)
Dim Bullet_Image(total_num_lazors,numrotations)
Dim xSinTable#(numrotations)                     ;Holds our SIN data
Dim yCosTable#(numrotations)                     ;Holds our COS data
;_______________________________________________________________________________________________________
;Function Calls INITIALIZE TURRETS______________________________________________________________________
;selection of player turrit images that shoot 360 directional bullets
;********************************************************************
lazor_cannon_im = CreateImage(20,20);	1							*
Make_lazorcannon_im(lazor_cannon_im);								*
;																	*
pulsar_cannon_im = CreateImage(20,20);	2							*
Make_pulsarcannon_im(pulsar_cannon_im);								*
;																	*
photon_cannon_im = CreateImage(20,20);	3							*
Make_photoncannon_im(photon_cannon_im);								*
;********************************************************************
Do_Turret_array(lazor_cannon_im,pulsar_cannon_im,photon_cannon_im)
Make_Turret_type(GraphicsWidth() Sar 1,GraphicsHeight() Sar 1,1)

;Make the 360 directional mouse guided bullets
green_lazor_im=CreateImage(6,20) ;index 1
Make_green_lazor(green_lazor_im)
MidHandle green_lazor_im

yellow_lazor_im=CreateImage(6,20) ;index 2
Make_yellow_lazor(yellow_lazor_im)
MidHandle yellow_lazor_im

purple_lazor_im=CreateImage(6,20) ;index 3
Make_purple_lazor(purple_lazor_im)
MidHandle purple_lazor_im

Do_lazor_array(green_lazor_im,yellow_lazor_im,purple_lazor_im)
PrecomputeSinCosTables()
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;*****************************************************************************************************

SetBuffer BackBuffer()
TFormFilter 1

quit = displaystartscreen()

While quit = False 
WaitTimer(frameTimer) 

	endgame = False
	
	old_level = 0 : control\level = 1 : control\nextextralife = 2500
	make_player	
	While endgame = False;Start of main Game loop_____________________start of main loop_________________
		WaitTimer(frameTimer);+++	
		If old_level <> control\level Then
			Introduce_Level
			;Make new bonneses and turrets for next leval 
			StartNewLevel
			old_level = control\level
		End If
		
		If player\lives<=0 Then endgame =True 
		
		time# = MilliSecs();Game Timing ????????????????????????????????????????????????????
		
		If player\score > control\nextextralife Then
			control\nextextralife = control\nextextralife + 2500
			player\lives = player\lives + 1
		End If
		
		Move_stars	
		Display_Info
		af = (af + 1) And 15 ;af___________af_______________af_______????????????????????
	
		min_x = control\xres
		max_x = 0
; ufo________________-ufo--------------ufo_______________ufo_____________--ufo_____________________
		new_ufo
		If ufo\status = True Then move_ufo

		bomb_count = 0
		For bombs = Each bomb_type
			bomb_count = bomb_count + 1
		 bombs\frame = bombs\frame + 1  ; +++ keep track of each frame of each bomb animation
		If bombs\frame = 16 Then bombs\frame = 0
			
		;DrawImage bomb_im1,bombs\x,bombs\y+10
		DrawImage bomb_im,bombs\x,bombs\y,bombs\frame
		
		
			 
			bombs\y = bombs\y + control\bomb_speed
		
			If ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(0),192,400,0) Then
				SetBuffer ImageBuffer(bases(0))
				Color 0,0,0
				bxp = bombs\x - 168
				byp = bombs\y -368
				draw_blank bxp,byp
				SetBuffer BackBuffer()
				Delete bombs
				bomb_count = bomb_count-1
			ElseIf ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(1),320,400,0) Then
				SetBuffer ImageBuffer(bases(1))
				Color 0,0,0
				bxp = bombs\x - 288
				byp = bombs\y -368
				draw_blank bxp,byp	
				SetBuffer BackBuffer()
				Delete bombs
				bomb_count = bomb_count-1
			ElseIf ImagesCollide(bomb_im,bombs\x,bombs\y,0,bases(2),448,400,0) Then
				SetBuffer ImageBuffer(bases(2))
				Color 0,0,0
				bxp = bombs\x - 420
				byp = bombs\y -368
				draw_blank bxp,byp
				SetBuffer BackBuffer()
				Delete bombs
				bomb_count = bomb_count-1
			ElseIf ImagesCollide(bomb_im,bombs\x,bombs\y,0,ship_im,player\x,player\y,0) Then
				If player\shield_Active = False Then
					bomb_count=bomb_count-1
					Player\lives = player\lives-1
					For i = 0 To 10
						ClsColor Rnd(255),Rnd(255),Rnd(255)
						Cls
						Flip
					Next
				End If
				Delete bombs
			Else If bombs\y > 480 Then
				Delete bombs : bomb_count=bomb_count-1
			End If
			
		Next

	
		check_bullets_and_bases
	
		player\moved = False;????????????????????????????????????????????????????????
		
		If MilliSecs()>player\shield_timer + 5000 Then;TTTTTTTTTTTTTTTTTTTTTTTTTTTTT
			player\shield_active = False
		Else
			Text 0,128,"Shield Active"
		End If
		
		If MilliSecs()>player\NES_Timer + 5000 Then
			player\Non_Expiring_Shot = False
		Else
			Text 0,144,"Non Expiring Shots"
		End If 
		
		
		If MilliSecs()>player\cluster_timer + 5000 Then
			player\cluster = False
		Else
			Text 0,160,"Cluster Fock"
		End If
		
		If MilliSecs()>Player\Speedy_Timer + 5000 Then
			control\player_speed = control\player_startspeed
			player\speedy = False
		Else
			Text 0,176,"Speedy"
		End If
		
		bomb_dropped = False
	
		beast_hit = False

		dokeys

		beast_count = 0
		
		mousepointer = 0
;Inside Main Loop ____________________________________________________________________________________
;LaunchBullet(Player_Turret\x,Player_Turret\y,Player_Turret\iDir)
If KeyHit(46) = True Then ;this goes in dokeys

	For Player_Turret.PTurret_type = Each PTurret_type
		;For i = 1 To 16
	 		LaunchBullet(Player_Turret\x,Player_Turret\y,Player_Turret\iDir,Player_Turret\selected)
		;Next 
	Next 
End If



picked = get_picked(picked);Get keyboard and mouse input and asign picked accordingly

mousepointer=pick_pointer(picked);

Pick_A_Turret(picked)

UpdateBullets()

;Hud()

;_____________________________________________________________________________________________________

		For beast = Each beast_Type  ;Checking beasts 
		

		
			If beast\deleted = False Then
				beast_count = beast_count + 1
				x = beast\x + dir : y = beast\y
				If inc_y = True Then y = y + control\crit_drop_speed
				If dir > 0 Then
					If x > max_x Then max_x = x
				Else
					If x < min_x Then min_x = x
				EndIf
							
				If ImagesCollide(im(af), beast\x,beast\y,0,bases(0),192,400,0) = True Then;af 
					FreeImage bases(0) : bases(0) = CreateImage(1,1)
				Else If ImagesCollide(im(af), beast\x,beast\y,0,bases(1),320,400,0) = True Then;af
					 FreeImage bases(1) : bases(1) = CreateImage(1,1)
				Else If ImagesCollide(im(af), beast\x,beast\y,0,bases(2),448,400,0) = True Then;af
					FreeImage bases(2) : bases(2) = CreateImage(1,1)
				End If				
				beast\x = x
				beast\y = y

				DrawImage im(af),beast\x, beast\y ;Draw the beast images.              af
				
				;Check for Turret bullets to beast collisions
				For B.Tbullet = Each Tbullet
					If ImagesCollide(im(af),beast\x,beast\y,0,Bullet_Image(B\selected,B\iDir),B\dX#,B\dY#,0) Then
						Delete B
						Add_Point beast\x , beast\y
						player\score = player\score + 10
					
						beast_count = beast_count-1 : beast_hit = True
					
						Make_Explosion beast\x,beast\y,5	
									
						beast\deleted = True
						
						;If player\cluster = True Then 
							;bullet\x = bullet\x + (Rand(128)-64)
							;bullet\y = bullet\y + (Rand(128)-64)
						;Else If player\non_expiring_shot = False Then 
							;bullet\fired = False
						;End If

					EndIf 
				
				Next 
				
				For bullet.Bullet_Type = Each Bullet_Type
				;If bullet <> Null Then 
				If bullet\fired = True Then;row 1069
					If ImagesCollide(im(af),beast\x,beast\y,0,bim,bullet\x,bullet\y,0) Then ;af

						Add_Point beast\x , beast\y
						player\score = player\score + 10
					
						beast_count = beast_count-1 : beast_hit = True
					
						Make_Explosion beast\x,beast\y,5	
									
						beast\deleted = True
						
						If player\cluster = True Then 
							bullet\x = bullet\x + (Rand(128)-64)
							bullet\y = bullet\y + (Rand(128)-64)
						Else If player\non_expiring_shot = False Then 
							bullet\fired = False
						End If
						
					EndIf
				EndIf
				;EndIf 
				Next 
				 
				If bomb_dropped = False Then
					If bomb_count < control\max_bombs Then
						If Rand(100)<control\drop_bomb_chance Then
							bomb_count = bomb_count+1
							bomb_dropped = True
							bombs = New bomb_type
							bombs\x = beast\x : bombs\y = beast\y
						EndIf
					EndIf
				EndIf
				
			EndIf
			
			If beast\y > 460 Then endgame = True
		Next ;end of beasts checking
	
		If beast_hit = True Then Increase_Beast_Speed
  
		inc_y = False
		If dir >0 Then
			If max_x > 608 Then dir = -dir : inc_y = True
		Else
			If min_x < 32 Then dir = - dir : inc_y = True
		EndIf
;Game update section *******************************************************************************
;***************************************************************************************************
;***************************************************************************** Game update section
		Do_Points	
		DoExplosion
		Move_Bonus_Item
		If ufo\status = True Then Check_Bullets_And_Ufo;ufo_____________ufo_____________________
		;If time# > frameTimer Then
			Move_And_Draw_Bullet
		;EndIf 
		If beast_count = 0 And ufo\status = False Then control\level = control\level + 1
		
		DrawImage ship_im,player\x,player\y
		
		;For Player_Turret.PTurret_Type = Each PTurret_Type
		
			;DrawImage Player_Turret\image,player\x,player\y
			;DrawImage Player_Turret\image,player\x,player\y
			;DrawImage Player_Turret\image,player\x,player\y
			;DrawImage Player_Turret\image,player\x,player\y


		;Next 
		;update_turret(player\x,player\y,drawcurent)
		;update_turret(player\x,player\y,lazor_cannon_im)
		
		;update_turret(player\x,player\y,pulsar_cannon_im)
		
		;update_turret(player\x,player\y,photon_cannon_im)


		DrawImage bases(0),192,400
		DrawImage bases(1),320,400
		DrawImage bases(2),448,400
	
		;Color 255,255,255
		;mousepointer=0
		;move Left
		If MouseDown (1) Then 
			mousepointer = 1
		End If
		;move Right 
		If MouseDown (2) Then 
			mousepointer = 2
		End If
		
 
		;DrawImage targetpointimage1,100,100 
		;DrawImage targetpointimage2,100,150 
		;DrawImage targetpointimage3,100,200 
		;DrawImage targetpointimage4,100,250
		;DrawImage targetpointimage5,100,300
		
		;For Player_Turret.PTurret_Type = Each PTurret_Type
			;DrawImage Player_Turret\image,100,350
		;Next 

		;Color 255,100,100
		;Line player\x,player\y-7,MouseX(),MouseY()
		;Color 0,0,0
		;Line player\x,player\y-10,MouseX()+1,MouseY()
		;Color 0,0,0
		;Line player\x,player\y-10,MouseX()-1,MouseY()
		;DrawImage bullet_im,150,100
		
		
		;If time# > rtimer# Then 

			;rframe=rframe+1
		    ;If rframe = 16 rframe = 0
			;DrawImage Quazar_im,150,150,rframe
			;If rframe > 2 
				;DrawImage Quazar_im,150,150,rframe-1

			;EndIf 
			;If rframe > 4
				;DrawImage Quazar_im,150,150,rframe-2

			;EndIf 

			;rawImage Quazar_im,150,150,rframe

			
			
			;DrawImage rappedfire_im,150,200,bullet\frame
			;DrawImage bomb_im,150,250,rframe

		;EndIf 

		



		
		

		
		;Text 30,420,"adjusttimer " + adjusttimer
		Color 100,200,100
		Text 20,420," Total vidio memory ; " + TotalVidMem()
		Text 275,420, "Available vidio memory : " + AvailVidMem ()
		Text 500,30, "Total beasts : " + total_beasts
		Memory_in_use = TotalVidMem() - AvailVidMem ()
		Text 20,440," Total vidio memory - " + "Available vidio memory  " + Memory_in_use
		


		VWait   
		
		 Flip False   
		rtimer# = MilliSecs()
  		If KeyDown (13) Then 
			adjusttimer = adjusttimer - 1
		EndIf
		If KeyDown (12) Then 
			adjusttimer = adjusttimer + 1
		EndIf 
		;EndIf 
		
		Delay adjusttimer
	Wend
	
	DisplayEndScreen
	EnterHighScore
	endgame = False
		
	;Delay(500)
	FlushKeys
	
	quit = displaystartscreen()	
Wend;main____________________MMMAAAIIINNN___________________end of main loop!
End


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



Function Make_Quazar() ;energy star bullets
For frame = 0 To 15

	SetBuffer ImageBuffer(Quazar_im,frame)
	;ResizeImage Quazar_im,24,24
	midx = ImageWidth(Quazar_im)/2;+Rnd(-3,3)
	midy = ImageHeight(Quazar_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,255),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
	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 255,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

	
	For l = 0 To 60
		;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=>30 Then 
			Line midx,midy,Rnd(midx-8,midx+8),Rnd(midy-8,midy+8)
		EndIf 
		If l=>40 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

	
	;center
	funct_used = funct_used+1
	Color 200+frame*3,200+frame*3,200+frame*3
	Color 255,200,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
		
	Oval -5,-5,10,10,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 f = 1 To 15 Step 4

	SetBuffer ImageBuffer(Quazar_im,f)
	angle# = f
	;ResizeImage Quazar_im,10.0*f,10.0*f
	RotateImage Quazar_im,angle#
	
Next 

;For f = 0 To 15 
;SetBuffer ImageBuffer(Quazar_im,f)
 	;DrawImage (Quazar_im,frame,frame,frame-1)
	;ResizeImage Quazar_im,170.0,170.0

;Next 
;For f = 11 To 15
;SetBuffer ImageBuffer(Quazar_im,f)

	;ResizeImage Quazar_im,100.0,100.0

;Next 




End Function

;BULLET********************BULLETS*********************BULLETS****************************BULLETS

Function Make_Ufo_im()
	ufo_im = CreateImage(100,100)
	;Color 0,255,0
	SetBuffer ImageBuffer(ufo_im)
	;rockets
For i = 1 To 3
	Color 75-(10*i),75,75-(10*i)
	Line 25+i,60,25+i,95-(i*5) ;left rocket
	Line 25-i,60,25-i,95-(i*5)
	Line 75+i,60,75+i,95-(i*5) ;right rocket
	Line 75-i,60,75-i,95-(i*5)
Next
Line 25,60,25,70
Line 75,60,75,70
Color 175,75,75
Line 25,65,25,95
Line 75,65,75,95
;mid section
For i = 1 To 4 ;neck
 	Color 40,80,40
	Line 50+i,20+(i*7),50+i,100-(i*7) 
	Line 50-i,20+(i*7),50-i,100-(i*7)
Next 
For i = 1 To 4 ;neck highlight
	Color 70,100,70
	Line 50+i,20+(i*7),50+i,90-(i*7) 
	Line 50-i,20+(i*7),50-i,90-(i*7)
Next 
For i = 1 To 3
	Line 50+i,0+(i*10),50+i,60 
	Line 50-i,0+(i*10),50-i,60
Next
 
;wings
For i = 1 To 25
	Color 55+i,75+(i*2),25+i
	Line 50-i,40+i,50-i,60+i
	Line 50+i,40+i,50+i,60+i
Next 
;wing tips
Line 75,65,75,84
Line 25,65,25,84
For i = 1 To 25
	;Color 125-i,150-i,125-i
	Color 80-i,130-(i*3),50-i
	Line 75+i,65-i,75+i,85-Ceil(i*1.75)
	Line 25-i,65-i,25-i,85-Ceil(i*1.75)
Next 
;head
Color 30,80,30
For i = 1 To 10
	Line 50+Ceil(i/2),100-i,50-Ceil(i/2),100-i ;forhead
Next 
For i = 1 To 5
	Line 45+i,90-i,55-i,90-i 
Next
Color 25,25,25
For i = 1 To 5
	Line 50+Ceil(i/2),97-i,50-Ceil(i/2),97-i ;forhead
Next 
Color 175,75,75
Line 50,0,50,10 
;center body and rocket centers
Color 50,70,20
Line 50,38,50,63 ;wings center line
Color 70,90,70
Line 50,10,50,86
For i = 1 To 75 Step 6
Color 175-i,75-i,75-i
Plot 50,0+i
Next 
Color 70,90,70
Line 51,56,75,80
Line 49,56,25,80
Line 90,55,75,80
Line 10,55,25,80

ScaleImage ufo_im,.5,.25
RotateImage ufo_im,90	
End Function

Function SpaceyText(x,y,message$,centre)
If Len(message)>0 Then
	If centre = True Then
		length = Len(message) * ImageWidth(spaceyfont(0))
		xs = (640-length)/2
	Else
		xs = x
	End If
	
	For c = 1 To Len(message)
		v = 0
		ch$ = Mid$(Upper(message), c, 1)
		If ch>="0" And ch<="9" Then 
			v = 26 + Asc(ch)-48
		Else If ch>="A" And ch<="Z" Then 
			v = Asc(ch)-65
		Else
			v = 36
		End If
		
		DrawImage spaceyfont(v),xs + (c * ImageWidth(spaceyfont(0))), y
	Next			
End If
End Function

Function Make_Bonus_Images()
Bonus_im = CreateImage(64,16,8)
For i = 0 To 7
	SetBuffer ImageBuffer(bonus_im,i)
	ClsColor i Shl 5,0,0
	Cls
	Color 64,192,64
	Rect 0,0,64,16,False
	Text 8,2,"BONUS"
	SetBuffer BackBuffer()
Next
End Function

Function Move_Bonus_Item()
If bonus\active = True Then
	bonus\y = bonus\y + 4
	If MilliSecs() > bonus\frametimer + 100 Then
		bonus\frame = (bonus\frame + 1) And 7
		bonus\frametimer = MilliSecs()
	End If
	DrawImage bonus_im,bonus\x, bonus\y, bonus\frame
	If ImagesCollide(bonus_im, bonus\x,bonus\y,0, ship_im, player\x, player\y,0) Then
		bonus\active = False
		Choose_Bonus_Type
	End If
	If bonus\y > 600 Then bonus\active = False
End If
End Function

Function Choose_Bonus_Type()
bt = Int(Rand(6))+1
Select bt
	Case 1
		; Shield
		player\Shield_Active = True
		player\Shield_Timer = MilliSecs()
	Case 2
		; Non-expiring shot
		Player\Non_Expiring_Shot = True
		Player\Nes_Timer = MilliSecs()
	Case 3
		; Speed
		Player\Speedy = True
		Player\Speedy_Timer = MilliSecs()
		control\Player_speed = control\Player_StartSpeed Shl 2
	Case 4
		; Cluster fock
		Player\cluster = True
		Player\Cluster_timer = MilliSecs()
	Case 5
		; Rebuild bases
		Make_Bases		
	Case 6
		player\lives = player\lives + 1
		; Extra Life
End Select

End Function

;Becky Roses wierd way of doing sound in code
.shoot
Data 4810
Data 82,73,70,70,194,18,0,0,87,65,86,69,102,109,116,32,18,0,0,0,1,0,1,0,64,31,0,0,64,31,0,0,1,0,8,0,0,0,102,97,99,116,4,0,0,0,143,18,0,0,100,97,116,97,143,18,0,0,126,163,97,101,124,137
Data 134,110,112,120,154,131,117,116,152,132,141,155,80,104,221,66,135,200,59,112,244,129,56,188,155,61,114,208,47,88,198,89,59,162,204,46,109,207,113,84,189,194,40,111,234,125,51,146,215,68,72,202,156,43,97,207,127,88,109,205,90,93,121,204
Data 89,87,127,220,84,85,133,211,84,93,122,200,88,79,115,193,116,70,94,177,164,64,73,160,214,61,60,138,207,126,54,95,161,210,79,49,135,199,148,77,76,136,210,159,38,91,170,192,141,58,107,136,197,143,41,83,146,209,145,64,80,142,186,199
Data 100,63,121,150,205,143,43,88,142,180,188,82,41,95,163,199,191,92,57,113,153,184,181,81,41,112,145,183,205,113,36,104,128,162,203,152,73,60,117,143,182,191,129,45,52,118,160,178,185,153,48,51,131,139,168,193,153,93,44,89,148,152,172,188
Data 140,73,48,100,144,161,171,191,160,88,41,78,136,159,155,183,182,149,69,43,93,139,153,155,183,178,163,88,36,81,114,155,158,155,179,172,146,76,43,50,121,155,159,164,160,170,169,142,78,38,52,103,151,166,159,157,160,166,160,140,83,38,55,82
Data 142,165,162,163,147,154,165,154,145,114,55,44,53,103,148,168,169,161,155,145,145,156,151,144,125,106,60,49,58,85,134,156,174,171,161,158,145,140,136,143,148,140,132,119,116,34,28,111,226,100,125,185,106,178,115,102,160,91,132,162,107,188,85,106
Data 102,96,186,91,163,121,92,179,86,150,130,92,163,88,155,126,92,153,87,174,104,146,124,92,194,87,180,92,98,100,95,198,79,201,79,126,144,121,152,88,192,88,195,83,112,81,113,151,87,147,90,201,82,204,82,144,112,97,101,100,177,86,157,89
Data 203,83,198,84,178,91,195,86,142,107,170,93,118,130,147,103,109,147,135,111,103,156,125,107,92,154,115,109,99,149,92,104,107,136,98,99,122,113,105,90,144,98,127,85,187,90,168,87,207,85,210,97,160,94,171,119,104,118,110,188,86,184,86,184
Data 88,179,89,106,120,101,124,96,203,84,207,87,126,106,111,114,86,200,85,205,101,118,113,86,201,83,203,103,106,121,97,204,86,174,92,97,164,90,205,98,120,114,100,161,88,163,97,115,199,85,197,93,101,174,90,209,108,106,163,90,147,106,104,157
Data 81,134,102,100,199,88,122,121,84,173,97,110,210,88,134,113,89,177,101,109,171,89,121,132,95,142,113,100,212,101,106,198,86,110,177,86,157,158,86,168,101,88,170,98,102,171,97,104,208,98,100,210,85,101,209,92,112,192,92,107,208,85,102,207
Data 87,110,179,95,104,205,116,95,169,105,87,134,135,91,117,197,83,121,203,92,105,203,121,92,143,128,84,118,204,82,103,172,106,99,153,189,82,119,209,106,99,147,126,78,112,203,84,88,129,162,84,106,171,107,94,124,210,86,108,130,189,83,117,144
Data 146,87,124,164,117,90,129,185,105,93,129,202,96,97,131,203,96,97,130,206,100,94,126,210,108,90,125,196,135,81,121,166,182,75,113,143,211,85,101,131,169,115,85,122,137,195,78,105,126,176,109,85,123,136,208,79,103,124,150,158,79,103,130,176
Data 116,76,112,135,193,152,77,116,137,159,142,77,114,129,156,155,73,101,132,144,192,87,91,127,140,205,126,72,112,131,137,194,70,98,122,137,168,131,69,102,133,140,162,148,73,114,130,140,172,135,72,99,131,141,143,201,70,96,122,139,140,193,153,67
Data 107,133,140,138,195,85,80,112,134,141,139,184,98,74,118,132,139,138,175,169,64,100,132,140,141,135,189,135,67,108,132,138,139,136,176,159,62,99,129,138,139,138,142,184,105,71,114,137,140,141,135,135,167,131,67,107,128,140,138,136,136,133,172,109
Data 65,98,129,140,140,138,134,134,132,167,116,65,94,130,137,134,132,129,128,127,133,159,132,64,99,123,140,141,137,138,134,130,129,129,134,163,117,65,90,128,140,141,139,136,133,133,129,130,127,127,127,144,156,119,63,94,130,141,143,131,120,121,123,130
Data 115,113,115,119,121,113,112,114,130,119,118,118,139,127,125,126,139,122,124,121,132,118,121,115,140,126,124,126,129,118,118,114,124,122,136,127,121,120,128,124,115,132,119,146,118,125,118,143,125,147,126,136,120,145,116,126,125,121,131,112,132,113,157,124
Data 145,121,141,132,133,122,119,130,126,121,115,162,111,129,157,116,99,141,114,93,156,134,124,119,166,105,113,167,126,113,138,161,105,124,157,110,115,147,154,100,112,153,97,122,135,155,95,136,154,112,108,138,159,101,105,153,144,121,111,166,141,96,120,148
Data 139,98,115,161,131,109,124,158,151,95,137,155,143,105,109,170,150,98,108,137,169,107,97,134,155,134,96,119,159,150,111,108,133,173,129,95,126,132,166,116,93,132,148,143,96,98,129,154,143,118,96,128,158,150,112,104,129,153,154,111,108,125,142,162
Data 124,111,104,126,168,134,102,103,119,147,158,131,98,109,124,150,158,121,100,109,132,158,159,128,101,111,125,155,158,129,113,98,122,146,152,151,115,96,115,136,144,154,139,111,92,119,137,142,159,141,100,99,105,132,145,148,150,128,91,96,127,136,143,153
Data 146,111,95,104,127,139,149,152,148,128,92,92,123,137,139,149,156,141,110,90,99,123,138,140,144,147,145,116,96,98,115,135,138,141,147,147,150,123,94,93,106,129,140,142,139,147,150,139,126,94,94,109,133,142,144,141,142,149,144,135,114,100,90,102
Data 130,138,144,143,137,136,138,139,136,127,110,91,93,103,124,142,145,145,142,136,135,136,140,138,128,125,108,96,94,105,120,137,147,149,145,142,137,133,132,133,136,135,130,126,123,93,77,99,157,122,145,121,124,143,119,135,131,117,141,113,126,141,120,141
Data 115,121,124,117,141,119,119,130,115,138,122,132,131,116,140,112,134,128,117,136,114,138,119,134,125,117,144,115,144,114,122,116,120,145,111,145,111,132,127,131,128,117,147,116,146,110,130,127,131,126,118,147,119,147,112,138,113,141,115,125,113,127,129,118
Data 123,120,143,114,138,116,148,113,146,113,144,114,148,113,140,116,146,114,137,118,126,113,134,115,122,111,130,116,124,112,135,116,128,113,139,115,134,114,146,114,140,115,150,114,148,118,143,116,148,125,127,123,131,135,115,133,116,149,114,149,113,148,117,137
Data 118,136,132,117,133,115,148,113,149,113,125,125,121,145,113,148,113,132,121,125,125,114,148,113,149,121,122,127,116,150,114,147,116,135,135,115,145,114,133,123,120,132,114,148,117,132,139,114,151,114,120,132,116,148,119,126,129,117,149,117,127,128,114,148
Data 114,123,144,111,144,118,115,150,113,136,124,115,151,117,124,151,115,137,125,115,149,118,121,153,115,127,131,114,135,126,116,143,122,118,149,119,119,146,113,119,143,113,135,142,113,136,125,116,135,125,114,152,126,115,150,120,115,145,122,117,137,125,115,149
Data 131,113,139,123,113,129,133,114,122,144,113,125,154,115,119,154,122,116,148,121,113,128,135,113,128,153,114,120,155,125,115,138,129,113,123,153,114,116,140,128,114,123,156,113,117,131,130,111,124,153,117,116,138,148,112,122,154,132,113,125,154,122,115,130
Data 144,112,117,136,134,112,120,143,128,113,122,146,125,113,122,147,125,113,121,145,126,112,121,139,131,111,118,133,141,110,116,128,153,111,113,127,156,119,111,123,139,134,110,117,129,155,113,112,124,142,131,110,117,129,157,127,110,123,134,156,115,114,126,133
Data 152,111,117,125,137,146,109,113,127,137,142,113,114,126,136,147,115,113,127,133,153,122,110,124,130,142,137,106,111,125,130,154,124,107,121,130,133,155,110,113,124,132,139,145,112,111,126,132,135,155,111,112,123,131,134,156,113,107,121,131,133,139,145,106
Data 114,124,131,132,151,137,105,116,128,132,133,147,127,105,113,127,132,132,135,148,107,106,122,131,133,132,140,139,104,109,124,131,132,131,136,145,105,111,122,131,132,132,131,145,128,104,112,126,132,133,132,131,141,136,109,109,124,132,133,133,131,130,137,142
Data 106,111,122,130,133,132,132,130,130,142,130,106,109,125,131,131,130,129,128,128,127,138,135,110,106,122,131,134,133,132,131,130,128,128,129,137,139,107,108,119,130,133,133,133,132,130,129,128,127,127,127,133,139,129,104,109,121,131,134,135,128,136,126,131
Data 126,133,124,127,125,130,122,125,123,127,124,125,123,126,125,127,123,128,125,127,124,128,124,125,128,125,125,127,126,130,124,126,125,127,123,128,125,134,124,129,126,131,125,133,126,132,126,131,127,128,127,128,130,124,126,126,131,125,131,122,130,127,135,126
Data 131,127,131,129,128,130,123,129,128,129,118,137,123,118,133,127,113,124,144,112,133,144,122,121,144,134,113,142,132,117,125,144,119,112,140,127,119,134,141,116,117,143,131,120,128,142,122,115,139,127,121,120,142,121,114,132,139,122,117,131,141,114,120,136
Data 136,116,118,140,135,116,118,134,142,113,124,136,139,118,116,130,143,117,116,125,143,124,112,123,137,135,113,113,134,143,121,114,121,144,134,118,120,128,146,135,112,124,136,143,131,112,122,137,144,125,111,124,140,142,123,114,120,137,145,125,115,117,133,147
Data 138,114,115,125,137,140,120,113,116,130,145,134,118,114,122,137,147,135,114,115,121,136,146,132,120,113,123,139,145,140,123,110,121,132,140,143,127,112,113,129,135,141,146,123,108,117,126,135,145,142,126,111,112,123,134,139,141,134,113,108,122,129,135,141
Data 140,130,110,112,124,132,137,141,141,130,114,106,120,131,134,138,143,138,128,111,109,121,129,136,137,139,141,130,113,108,113,126,133,136,136,140,140,128,116,106,112,125,134,136,135,138,139,138,129,111,107,109,124,134,138,136,134,138,137,136,128,114,106,108
Data 120,132,137,137,135,133,134,135,133,129,120,111,107,111,123,131,137,138,137,133,133,132,135,134,131,127,118,110,107,111,120,131,136,139,138,137,135,133,130,131,132,132,130,127,126,118,101,107,124,134,135,125,133,127,126,132,123,129,131,122,129,122,126,132
Data 121,132,124,124,133,122,132,126,124,130,122,131,126,130,130,122,132,121,131,128,123,130,121,132,124,131,126,124,134,123,133,121,127,122,126,132,121,131,121,131,125,125,125,125,134,120,134,120,131,124,131,124,126,133,127,132,122,134,123,134,121,130,121,132
Data 123,127,122,128,129,124,126,126,133,122,135,124,135,122,134,123,135,122,134,123,135,121,133,121,133,119,130,120,134,120,133,122,135,121,134,123,135,122,136,125,134,123,136,127,129,126,131,130,124,129,125,128,121,133,121,132,122,136,122,136,126,129,125,128
Data 132,121,132,122,135,122,135,127,125,127,124,135,122,136,122,129,126,126,127,121,135,121,136,122,126,127,123,130,121,136,122,133,130,122,133,121,133,125,127,129,122,137,123,134,131,122,135,122,129,128,122,132,123,132,126,125,137,122,134,125,122,136,122,134
Data 124,120,135,121,131,132,121,137,122,122,135,122,135,131,122,138,123,122,136,122,134,132,122,137,124,122,138,123,128,136,122,131,128,122,134,127,122,137,125,122,137,121,122,136,121,128,136,121,128,130,121,126,131,121,126,133,121,132,135,121,129,130,121,125
Data 133,121,123,136,121,126,138,122,123,137,125,121,139,124,122,133,129,121,134,135,121,125,135,123,122,139,123,121,132,130,121,124,139,122,123,135,129,121,131,138,122,124,141,129,119,127,133,121,121,137,126,120,124,139,122,123,130,134,121,124,136,129,121,127
Data 140,125,121,130,141,123,122,132,139,122,122,134,138,121,123,135,138,121,122,133,138,121,122,131,140,121,121,129,141,124,120,126,141,127,119,125,139,135,119,123,131,141,122,120,127,136,130,119,124,128,140,121,120,125,135,132,119,121,127,141,125,119,123,129
Data 141,127,119,124,131,140,125,119,125,131,141,124,119,125,129,141,125,118,123,129,139,130,119,121,128,134,142,122,117,124,127,136,130,117,119,127,130,142,130,117,123,129,131,142,124,118,125,129,131,142,123,117,123,129,131,137,133,117,122,126,130,133,139,124
Data 116,124,129,130,134,136,117,117,124,129,131,133,139,118,118,123,128,130,131,139,126,116,122,129,130,131,133,136,122,116,123,129,130,130,131,138,125,115,122,128,130,130,130,135,137,118,117,125,129,130,130,130,131,138,121,116,121,128,130,131,130,129,132,137
Data 119,115,122,128,130,131,130,129,129,132,137,119,116,121,128,130,129,129,128,128,127,129,136,122,115,119,127,131,131,130,130,129,128,128,128,132,135,120,114,120,128,131,131,131,130,129,129,128,128,127,127,128,133,131,121,114,121,128,130,136,129,131,127,129
Data 127,130,127,129,126,129,127,129,126,128,126,129,126,127,126,128,126,128,126,129,126,128,126,129,125,127,126,128,126,129,126,130,126,128,127,128,126,130,127,129,127,129,128,127,127,129,128,126,128,127,127,126,129,126,128,126,129,127,129,127,130,128,130,128
Data 127,128,128,128,126,129,126,127,126,128,123,125,130,122,129,133,124,124,136,125,122,135,127,124,130,133,121,132,135,124,125,135,129,120,132,130,123,124,134,124,121,133,132,123,123,134,127,120,128,134,124,123,130,133,121,127,134,129,122,127,137,127,123,130
Data 133,128,122,131,133,125,122,129,136,126,120,130,135,128,121,126,136,129,122,125,134,135,122,123,131,135,126,119,128,135,130,122,123,128,137,125,122,125,134,134,121,123,127,135,132,120,120,131,137,129,121,121,132,136,132,122,122,130,137,133,122,121,126,136
Data 135,123,121,122,130,135,131,120,120,127,134,136,125,120,121,129,137,134,122,119,122,131,137,136,125,119,123,128,135,136,127,119,120,128,134,137,134,121,118,123,129,134,138,132,120,120,125,129,135,137,129,121,116,123,129,132,136,133,122,116,119,127,131,134
Data 136,131,120,118,121,127,132,135,136,133,122,116,118,126,131,133,135,136,130,120,116,119,127,132,132,134,136,131,125,116,118,125,130,133,133,134,135,132,123,116,117,122,129,132,132,133,134,134,130,123,116,116,123,128,133,133,132,133,134,133,129,124,117,115
Data 121,127,132,133,132,131,131,132,131,129,126,119,115,117,121,128,133,134,133,132,131,130,131,131,130,128,125,119,116,117,119,126,131,134,134,133,132,131,130,129,130,130,130,128,127,124,117,112,122,131,131,129,130,127,127,128,126,129,128,128,129,125,127,126
Data 126,129,125,129,127,126,129,125,129,127,126,128,125,129,127,128,128,125,129,125,129,127,125,128,125,129,126,127,127,126,130,124,130,125,128,128,127,129,125,130,125,129,126,127,126,127,129,125,129,125,129,125,130,125,128,128,128,128,126,130,126,130,125,130
Data 125,130,125,129,127,129,126,128,129,128,127,127,130,128,129,126,130,127,129,126,131,127,130,125,129,126,129,125,130,126,129,126,130,127,129,126,130,128,128,127,129,127,126,129,127,128,125,130,125,129,125,131,125,130,126,130,126,127,128,127,128,125,130,125
Data 130,125,130,126,130,128,126,128,125,130,125,130,125,131,127,127,128,126,130,125,131,125,127,128,126,129,125,131,125,130,128,125,130,125,130,126,128,127,125,131,125,131,128,125,130,125,130,127,127,129,125,131,126,128,128,125,132,126,129,130,125,131,126,125
Data 130,124,130,127,124,130,124,127,128,124,131,127,126,130,125,128,129,125,132,127,126,131,125,127,129,125,132,126,125,132,126,128,132,125,129,129,125,130,128,124,130,128,124,132,127,124,132,125,124,132,125,126,132,125,125,131,126,125,132,125,125,132,125,125
Data 132,126,125,132,125,124,132,126,124,130,128,124,131,130,124,128,130,125,125,132,125,124,132,127,124,129,130,124,128,133,125,125,133,128,124,130,130,125,125,133,126,124,129,130,124,126,132,126,123,130,131,124,125,133,129,124,127,132,126,124,130,130,125,125
Data 133,128,124,125,134,127,124,126,134,126,124,126,133,125,124,127,134,125,124,126,133,125,124,126,134,126,123,125,133,127,123,125,131,130,123,124,129,133,124,123,126,134,127,123,125,131,131,125,124,127,134,129,123,125,130,134,125,123,126,133,132,124,124,128
Data 133,130,123,125,127,134,128,123,124,128,134,128,123,124,127,134,132,123,124,128,130,134,125,123,126,129,135,127,122,123,127,131,134,124,122,126,129,132,131,123,124,126,129,135,128,123,124,127,129,133,131,123,124,126,129,132,132,125,122,126,128,129,134,128
Data 122,123,127,129,131,134,126,121,125,127,129,130,134,124,121,124,127,129,129,133,129,121,122,126,129,129,129,134,127,121,123,127,129,129,129,133,128,121,122,126,128,129,129,130,133,124,121,123,127,129,129,129,129,133,126,122,123,127,129,129,129,129,130,132
Data 128,121,123,126,129,129,129,129,129,130,133,128,121,123,127,128,129,128,128,128,128,128,132,129,121,122,126,129,129,129,129,129,128,128,128,129,132,128,121,122,125,129,130,130,129,129,128,128,128,128,127,128,129,131,126,120,121,126,129,132,130,128,128,128
Data 128,127,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,127,127,128,127,128,127,128,127,127,128,128,127,127,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,128,128,127,128,128,127,128
Data 127,129,127,128,127,128,128,127,127,127,127,126,129,126,126,130,127,125,129,128,124,130,130,126,128,131,127,126,131,127,125,129,129,124,126,131,126,125,129,130,124,129,131,126,125,130,130,124,126,131,128,125,128,131,125,124,130,129,125,125,131,129,125,126
Data 130,129,124,125,131,128,124,126,131,129,124,126,131,129,124,124,131,130,125,124,128,132,126,123,127,131,128,124,125,131,130,125,124,127,133,128,124,125,130,132,128,123,126,131,132,126,123,128,131,131,125,124,126,132,131,125,124,126,132,132,127,124,126,131
Data 133,129,124,124,126,132,130,124,123,125,130,133,128,124,123,127,132,133,128,123,124,127,131,133,128,124,124,127,131,133,130,124,123,125,129,132,132,128,123,124,128,130,132,131,125,122,124,128,131,133,131,125,121,124,126,130,132,131,128,122,122,126,128,130
Data 133,131,127,122,123,127,129,131,132,131,128,122,121,126,128,130,132,132,131,126,122,122,126,128,130,131,132,132,127,122,121,123,127,130,130,131,132,131,126,123,121,123,127,129,130,130,131,132,130,126,121,120,122,127,130,131,130,130,131,131,130,126,122,120
Data 121,126,129,131,131,130,130,130,130,129,127,124,121,120,123,127,129,131,131,131,130,129,130,130,130,128,127,123,122,121,122,126,128,131,132,131,131,130,129,129,129,129,129,128,127,127,122,119,123,128,128,129,129,128,129,128,127,128,127,128,128,127,128,126
Data 127,127,127,128,127,128,127,127,128,126,128,127,127,128,127,128,127,127,128,127,128,127,128,127,127,128,127,128,127,127,127,127,128,126,128,126,128,128,128,128,127,128,127,128,126,128,126,128,128,127,128,127,128,126,128,126,128,127,127,127,127,128,127,128
Data 127,128,126,128,126,128,127,129,127,128,127,128,127,128,128,128,127,128,128,128,127,128,128,128,127,127,127,127,127,127,128,127,127,128,128,127,127,128,127,128,127,128,127,128,127,129,127,128,127,129,127,128,127,128,127,127,128,127,128,127,129,127,128,127
Data 128,127,128,127,127,128,127,128,126,128,127,128,128,127,128,127,129,127,128,127,127,128,127,128,127,128,127,128,128,127,128,126,128,127,128,127,126,129,127,129,128,127,128,127,129,127,128,128,127,129,127,128,127,127,129,127,129,128,127,129,127,128,128,127
Data 128,127,127,128,126,128,127,127,128,127,128,128,127,129,127,127,128,127,128,128,127,129,127,127,128,127,127,128,127,129,128,127,129,127,127,129,127,128,129,127,128,128,127,128,128,126,128,128,126,129,128,126,129,127,126,129,128,127,129,128,127,129,127,126
Data 128,127,126,128,128,126,128,128,127,128,128,127,127,129,127,127,129,127,127,128,128,127,128,128,127,127,128,127,127,129,127,127,128,128,127,128,129,127,127,129,128,127,128,129,127,126,128,127,126,127,129,127,126,128,128,127,127,129,128,127,127,129,127,127
Data 128,129,127,127,128,128,127,127,128,128,127,127,129,128,127,127,129,128,127,127,129,128,127,127,129,128,127,127,128,129,127,127,128,129,127,127,127,129,128,127,127,128,128,127,127,127,129,127,127,127,128,128,127,127,127,129,127,127,127,128,129,127,127,127
Data 128,128,127,127,127,129,129,127,127,127,128,128,127,127,127,128,129,127,127,127,128,129,128,127,127,128,129,128,127,127,127,128,129,127,127,127,127,128,128,127,127,127,128,128,128,127,127,127,128,128,128,127,127,127,128,128,129,127,127,127,127,128,128,128
Data 127,127,127,128,128,128,128,127,127,127,128,128,128,128,127,127,127,128,128,128,128,127,127,127,127,128,128,128,128,127,127,127,128,128,128,128,128,127,127,127,127,128,128,128,128,128,127,127,127,128,128,128,128,128,128,127,127,127,128,128,128,128,128,128
Data 128,127,127,127,128,128,128,128,128,128,128,128,127,127,127,128,128,128,128,128,128,128,128,128,127,127,127,127,128,128,128,128,128,128,128,128,128,128,127,127,127,128,128,128,128,128,128,128,128,128,127,128,128,128,128,127,127,127,128,128,128,128,128,127
Data 128,127,128,128,128,128,128,128,128,0

.makeSound
	Restore shoot
	Read ln
	pos=0

	Repeat
		fileName$="C:\sound"+Rnd(1,1000)+".wav"
		

	Until FileType(fileName)=0

	fileOut=WriteFile(fileName)
		For pos=0 To ln-1
			Read bt
			WriteByte fileOut,bt
		Next
	CloseFile fileOut

	Global shootSound=LoadSound(fileName)
	;chnsound=PlaySound ( shootSound )
	;ChannelPitch chnsound,4000
	;Delay 1000
	;thirdsound=PlaySound ( shootSound )
	;ChannelPitch thirdsound,5000
	;Delay 1000
	;fourthsound=PlaySound ( shootSound )
	;ChannelPitch fourthsound,9000


	;Global chnsound=PlaySound(shootSound)
	;ChannelPitch chnsound,4200
	
	
	DeleteFile fileName
Return

















Function Do_Turret_array(im1,im2,im3)

For turret_index = 1 To Total_num_turrets  
	For frame = 0 To Turret_Rotations - 1
		Select turret_index
			Case 1
				Turret_array_im(turret_index,frame) = CopyImage(im1)
			Case 2
				Turret_array_im(turret_index,frame) = CopyImage(im2)
			Case 3
				Turret_array_im(turret_index,frame) = CopyImage(im3)
			Case 4
				DebugLog "turret_index " + turret_index : WaitKey 
			Case 0
				DebugLog "turret_index " + turret_index : WaitKey
		End Select
		;ResizeImage Turret_array_im(turret_index,frame),Rnd(20,30),Rnd(20,30)
		RotateImage Turret_array_im(turret_index,frame),frame * 360/Turret_Rotations
	Next
Next
  
End Function 
;Make_Turret_type(midpoint\x,midpoint\y,1) ;The last variable of this function holds the index 

Function Make_Turret_type(x,y,selected)
	Player_Turret.PTurret_type = New PTurret_type
		Player_Turret\x=x : Player_Turret\y=y : Player_Turret\ammo=100
		Player_Turret\width=20 : Player_Turret\height=20
		Player_Turret\iDir = 0 ;not sure if this is needed
		Player_Turret\selected = selected
End Function

Function update_turret(x,y,selected);selected
	For Player_Turret.PTurret_type = Each PTurret_type
		Player_Turret\x = x : Player_Turret\y = y
		Player_Turret\selected = selected 
		Player_Turret\ammo=100
		
		
		;angle=ATan2( rotate\y+rotate\centery - MouseY(),rotate\x+ rotate\centerx - MouseX() )
		angle=ATan2(Player_Turret\y  - MouseY(),Player_Turret\x - MouseX() ) ; the angle between the curser and pointer
	
		angle=angle-90 ; subtract 90 from the angle to compinsate for the blitz co-ord system
		If angle>359 Then ; check angle is within 0-359 range
			angle=angle-359 ; if not, wrap it round
		ElseIf angle<0 Then
			angle=angle+359
		End If
		Text 20,300,"angle? " + angle
		;Line MouseX(),MouseY(),Player_Turret\x,Player_Turret\y
		;player\iDir = angle
		Player_Turret\frame = angle
		Player_Turret\iDir = angle
 		If Player_Turret\selected > 3 Then 
			Player_Turret\equiped = 3
		ElseIf Player_Turret\selected < 1 Then 
			Player_Turret\equiped = 1
		Else
			Player_Turret\equiped = Player_Turret\selected
		EndIf 
		;DrawImage Turret_array_im(Player_Turret\equiped,Player_Turret\frame),MouseX(),MouseY()
		DrawImage Turret_array_im(Player_Turret\equiped,Player_Turret\frame),Player_Turret\x,Player_Turret\y
		

	Next
End Function 

;Function Make_temppoint_im(temppoint_im)
;SetBuffer ImageBuffer(temppoint_im)
			;midx=ImageWidth(temppoint_im)/2
			;midy=ImageHeight(temppoint_im)/2
		
			;Color 255,55,255
		 	;Plot midx,midy
			
;SetBuffer BackBuffer()
;End Function

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

Function PrecomputeSinCosTables()
 Local iAngle# = 0
 ; run through the full rotation cycle, and use Sin and Cos
 ; at 10-degree increments
 For iAngle = 0 To numrotations-1
     xSinTable#(iAngle) = -Sin(iAngle);the iAngle multiplyer corasponds to numrotations 
     yCosTable#(iAngle) = Cos(iAngle); the multiplyer * numrotations must = 360 
		;Print xSinTable#(iAngle)
		;Print yCosTable#(iAngle)
		;a = a + 1
 Next
;Print "There are " + a + " precalculated angles in " + numrotations + " rotations"
;Delay 25000
End Function
Function LaunchBullet.TBullet(Player_X,Player_Y,iDir,selected)
        ; create a new Bullet instance
		B.TBullet = New TBullet

		; have it's starting point be the center of the player's ship
		
		
		B\dX = Player_X
		B\dY = Player_Y

		; and have it face the same direction as the player
		B\iDir = iDir ;set equal to player iDir

		;B\iDir = angle
		; give it a bit of a faster speed than the player
		B\dSpeedModifier = 7 ;speed of bullet

		; determine the player's speed amd create the bullet speed based on that
        B\dSpeedX# = (xSinTable#(B\iDir)) *  B\dSpeedModifier#
        B\dSpeedY# = (yCosTable#(B\iDir)) *  B\dSpeedModifier#
		
		B\selected = selected


        ; increment the number of bullets fired for this level
        iBulletsFired = iBulletsFired + 1
		BulletsFired = BulletsFired + 1
End Function

;*************************************************************
; FUNCTION: UpdateBullets()
; This function keeps the bullets moving, checks if they've
; hit anything, and kills them if they go off-screen
;*************************************************************
Function UpdateBullets()
 ; go through all of the bullets
 For B.TBullet = Each TBullet
	
 	;bullet ai
     ; update their x,y positions
     B\dX# = B\dX# - B\dSpeedX#
     B\dY# = B\dY# - B\dSpeedY#
	; check there range ; remember to make a range field
	
	 ;B\dx# = B\dx# + Rnd(-8,8)
 	 ;B\dY# = B\dY# + Rnd(-8,8)
; if the bullet is off the screen, or out of range or collides with a target, delete it, destroy = true
       
			If B\dX < 0 Or B\dX > 800 Or B\dY < 0 Or B\dY > 600 Then
 				;Delete B
				destroy = True 

        	
				
			Else
				destroy = False 
			EndIf 
			
					
			
				 
					
					
				


           ; otherwise, draw it
			;delete the bullet or not? True or false, yes or no, no abla engalish, abla english
			Select destroy
				Case False 
					DrawImage Bullet_Image(B\selected,B\iDir),B\dX#,B\dY#
				Case True 
					
					Delete B 
					If B = Null Then 
						destb = destb + 1
					EndIf 

			End Select 
			
			

 Next


Text 50,500,"destroy " + destroy 
Text 50,520,"destroyed bullets " + destb 
Text 30,540,"BulletsFired " + BulletsFired 

End Function



;______________________________________________________________________________________________________

Function get_picked(p) ;secondary wepon selection by keybourd input and mouse z speed				
	If KeyHit (2)  p=1 
	If KeyHit (3)  p=2
	If KeyHit (4)  p=3
	If KeyHit (5)  p=4
	If KeyHit (6)  p=5
			
	If KeyDown (203)=True  p=9
	If KeyDown (205)=True  p=10				 
					
	Select MouseZSpeed()
		Case 1
			p=p+1
		Case 0  
			mousepointer=p 
		Case -1 
			p=p-1
		End Select
	If p > Total_Num_Turrets Then p = (Total_Num_Turrets/Total_Num_Turrets) ;keep the player within the Turret index 
	If p < (Total_Num_Turrets/Total_Num_Turrets) Then p = Total_Num_Turrets 
	Return p 
End Function

Function pick_pointer(p)
	mousepointer = p 
	Select mousepointer 
		Case 1
			update_target_point(blankimage,targetpointimage1)												
		Case 2
			update_target_point(blankimage,targetpointimage2)
		Case 3
			update_target_point(blankimage,targetpointimage3)
		Case 4
			update_target_point(blankimage,targetpointimage4)
		Case 5 
			update_target_point(blankimage,targetpointimage5)
		Case 6 
		Case 7
	    Case 8 
		Case 9 
			update_target_point(gorightimage,blankimage)
		Case 10
			update_target_point(goleftimage,blankimage)
		Default 
			update_target_point(idoltargetimage,blankimage)
		End Select
		Return p 
End Function 

Function Pick_A_Turret(picked)
For Player_Turret.PTurret_type = Each PTurret_type
	Select Player_Turret\selected
		Case 1
			update_turret(player\x,player\y,Player_Turret\selected)
		Case 2
			update_turret(player\x,player\y,Player_Turret\selected)
		Case 3
			update_turret(player\x,player\y,Player_Turret\selected)
		Default
		 	update_turret(player\x,player\y,Player_Turret\selected)
		End Select
		Player_Turret\selected = picked 
Next
End Function

Function Do_lazor_array(im1,im2,im3)
	For lazor_index = 1 To total_num_lazors
		For frame = 0 To numrotations - 1
			Select lazor_index
			Case 1
 				Bullet_Image(lazor_index,frame)=CopyImage(im1)
			Case 2
				Bullet_Image(lazor_index,frame)=CopyImage(im2)
			Case 3
			 	Bullet_Image(lazor_index,frame)=CopyImage(im3)
			Case 4
				DebugLog "lazor_index " + lazor_index : WaitKey 
			Case 0
				DebugLog "lazor_index " + lazor_index : WaitKey
			End Select 
			RotateImage Bullet_Image(lazor_index,frame),frame*360/numrotations
		Next 
	Next
End Function 


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

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

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






  
Function Hud()
	;display = (midpoint\y Sar 1)
	;mousepoint\x=MouseX()	:	mousepoint\y=MouseY()
	;Text midpoint\x , midpoint\y  ,"graphics mid x = " + midpoint\x 
	;Text midpoint\x,midpoint\y + 10, "graphics mid y = " + midpoint\y
	
End Function




In my opinion, it's too hard. My apologies, RiverRatt. I thought no one was working on it any more.

Do you mean the code is too hard or the gameplay?

Where is the latest downloadable version of this?

It's 4 posts up in 3 sections cause it's so long. Jus't cut and paste one after another into the blitz editor. The one at the top is what I added to.

I can help out with some models. I'm helping out with the Derelict project right now so I won't have time to do anything for a few weeks, but I'll let you know.

Craig:This is a year old. Nobody is working on it anymore. People have moved onto other things.

yet its still sticky ...

This thread is too long for me to read at 05 am :D

i got a question ?

Is there a space invader with real 3d physics. ?

good question wings, a z axis to the guy at the bottom that'd be a challenge.

Isn't Space Invaders the name of the game they show you how to make in 3D Programming For Teens? Thats where I learned BB3D.

AJ00200