B3D Shooter

Miscellaneous Forums/Blitz Showcase/B3D Shooter

Hello I spent most of the day working on this.
AppTitle "3d Shooter"
Graphics3D 800,600,0,1
SeedRnd MilliSecs()
Const Number_of_enemies = 10
Global CenterX = GraphicsWidth()/2
Global CenterY = GraphicsHeight()/2
Global Abort = 0
Global FrameCount = MilliSecs()
Global Camera = CreateCamera()
Global Truce = 10000
Global DoFPS
Global Writing$ = "Press Enter to view FPS"
;assemble the player
Global CloneMe = CreatePivot()
Global Player = CreateCylinder()
EntityParent Player,CloneMe
EntityColor Player,0,0,255
Global XLook
Eyes = CreateImage(16,16)
SetBuffer ImageBuffer(Eyes)
Color 255,255,0
Rect 0,0,16,16
Color 255,0,0
Plot 4,8
Plot 12,8
Global FPSCalc = 0
TranslateEntity CloneMe,0,-7,1
TranslateEntity Camera,0,-3,1
ScaleMesh Player,1,3,1
Gun = CreateCylinder()
EntityParent Gun,CloneMe
PositionEntity Gun,0,2,2
ScaleMesh Gun,0.25,2,0.25
RotateEntity Gun,90,0,0
EntityColor gun,64,32,0
Sight = CreateCube()
ScaleMesh Sight,0.0125,0.1,0.1
EntityColor Sight,0,0,0
HeadTexture = CreateTexture(64,64)
SetBuffer TextureBuffer(HeadTexture)
Color 255,255,0
Rect 0,0,64,64
DrawImage Eyes,8,16
Global Grass = CreateTexture(32,32)
Global Light = CreateLight(2)
LightColor Light,10,10,10
EntityParent Light,Camera
Global Head = CreateSphere()
RotateEntity Head,0,-90,0
EntityParent Head,CloneMe
EntityParent Sight,CloneMe
PositionEntity Sight,0,2.25,3.75
EntityTexture Head,HeadTexture
PositionEntity Head,0,4,0
SetBuffer TextureBuffer(Grass);Make grass texture

Color 0,255,0
Rect 0,0,16,16
Rect 16,16,16,16
Color 0,250,0
Rect 16,0,16,16
Rect 0,16,16,16
SetBuffer BackBuffer()
EntityType CloneMe,17
EntityRadius CloneMe,3
EntityPickMode CloneMe,1
;done...
;make bullet
Bullet = CreateCylinder()
RotateEntity Bullet,90,0,0
ScaleMesh Bullet,0.125,150,0.125
EntityColor Bullet,255,255,16
Target = CreatePivot()
;RotateEntity Target,90,0,0
Color 255,128,0
;done...
;Build Enemies
Dim NPC(Number_of_enemies + 1)
Dim NPCName$(Number_of_enemies)
Dim NPCPrey(Number_of_enemies + 1)
Dim NPCDead(Number_of_enemies + 1)
Dim NPCInjurePoint(Number_of_enemies + 1)
Dim NPCFiredShot(Number_of_enemies + 1)
Dim NPCDirection(Number_of_enemies)
Dim NPCTime(Number_of_enemies)
Dim NPCGunshot(Number_of_enemies + 1)
Dim NPCInaccuracy#(Number_of_enemies + 1)
Dim NPCFiringDelay(Number_of_enemies + 1)
For loop = 1 To Number_of_enemies
NPCName(Loop) = Rename$()
NPC(Loop) = CopyEntity(CloneMe)
NPCGunshot(Loop) = CopyEntity(Bullet)
NPCInjurePoint(Loop) = CopyEntity(Target)
NPCInaccuracy(Loop) = Rnd(5,15)
EntityParent NPCInjurePoint(Loop),NPC(Loop)
PositionEntity NPCInjurePoint(Loop),0,2,1
HideEntity NPCGunshot(Loop)
EntityParent NPCGunshot(Loop),NPC(Loop)
PositionEntity NPCGunshot(Loop),0,2,150
NPCDirection(Loop) = Rnd(-1,1)
NPCTime(Loop) = Rand(1,100)
Next


NPC(Number_of_enemies + 1) = CopyEntity(CloneMe)
NPCGunshot(Loop) = CopyEntity(Bullet)
EntityParent NPCGunshot(Number_of_enemies + 1),NPC(Number_of_enemies + 1)
PositionEntity NPCGunshot(Number_of_enemies + 1),0,2,150
NPCInaccuracy(Number_of_enemies + 1) = Rnd(5,15)
HideEntity NPCGunshot(Number_of_enemies + 1)

NPCInjurePoint(Number_of_enemies + 1) = CopyEntity(Target)
EntityParent NPCInjurePoint(Number_of_enemies + 1),NPC(Number_of_enemies + 1)
PositionEntity NPCInjurePoint(Number_of_enemies + 1),0,2,1





HideEntity CloneMe
HideEntity Bullet
HideEntity Target

EntityParent Camera,NPC(Number_of_enemies + 1)



Collisions 17,17,1,2







Global Ground = CreatePlane()
EntityTexture Ground,Grass
TranslateEntity Ground,0,-10,0


Runtime()
End




Function Runtime();Runtime function

Repeat
Timer = MilliSecs()



UpdateNPCs()
MouseLook()
If Truce = 0 GunShot()
TurnEntity NPC(Number_of_enemies + 1),0,-Xlook/5,0
MoveEntity NPC(Number_of_enemies + 1),KeyDown(205) - KeyDown(203),0,KeyDown(200) * 2 - KeyDown(208)
UpdateWorld()
RenderWorld()
If KeyDown(28) Text CenterX,10,"FPS:",1,0
If KeyDown(28) Text CenterX,20,FPS(),1,0
Text CenterX,0,Writing,1,0
Flip


If KeyHit(1) Abort = 1


While Not MilliSecs() - Timer > 25
Wend
Until Abort = 1

End Function

Function MouseLook()

Xlook = MouseX() - CenterX
MoveMouse CenterX,CenterY
End Function



Function UpdateNPCs()
For Loop = 1 To Number_of_enemies
If NPCDead(Loop) = 0
NPCTime(Loop) = NPCTime(Loop) - 1
If NPCTime(Loop) < 1
NPCTime(Loop) = Rand(1,100)
NPCDirection(Loop) = Rnd(-1,1)
EndIf
If NPCPrey(Loop) = 0 TurnEntity NPC(Loop),0,NPCDirection(Loop),0

If Truce > 0
Truce = Truce - 1
If Truce = 0 Writing = "Let the killing begin!"
FlushMouse
Else
ChooseTarget()
Attack()
DeadTarget()
EndIf
If NPCPrey(Loop) = 0
MoveEntity NPC(Loop),0,0,1
ElseIf NPCDead(NPCPrey(Loop)) = 0
If EntityDistance(NPC(Loop),NPC(NPCPrey(Loop))) > 250 MoveEntity NPC(Loop),0,0,1
EndIf
EndIf
Next
End Function





;Function









Function Gunshot()


If MouseHit(1) NPCFiredShot(Number_of_enemies + 1) = 1








For Loop = 1 To Number_of_enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop) > 0
If NPCDead(NPCPrey(Loop)) = 0
NPCFiringDelay(Loop) = NPCFiringDelay(Loop) - 1
If NPCFiringDelay(Loop) <= 0
If EntityDistance(NPC(Loop),NPC(NPCPrey(Loop))) < 285
NPCFiredShot(Loop) = 1
NPCFiringDelay(Loop) = Rnd(30,40)
EndIf
EndIf
EndIf
EndIf
EndIf
Next





For Loop = 1 To Number_of_enemies + 1
If NPCDead(Loop) = 0
If NPCFiredShot(Loop) = 1
TurnEntity NPC(Loop),0,Rnd(-NPCInaccuracy(Loop),NPCInaccuracy(Loop)),0
ShowEntity NPCGunshot(Loop)

DeleteEntity% = EntityPick(NPCInjurePoint(Loop),300)
NPCFiredShot(Loop) = 2
ElseIf NPCFiredShot(Loop) = 2
NPCFiredShot(Loop) = 0
HideEntity NPCGunshot(Loop)
EndIf
EndIf

For Loop2 = 1 To Number_of_Enemies + 1

If NPC(Loop2) = DeleteEntity%
If NPCDead(Loop2) = 0
FreeEntity NPC(Loop2)
;NPC(Loop2) = 0
NPCDead(Loop2) = 1
If Loop2 = Number_of_Enemies + 1 GameOver(NPCName(Loop))
If Loop = Number_of_Enemies + 1 Kill(NPCName(Loop2))
EndIf
EndIf
Next
Next


;Is An NPC Dead

End Function













Function Rename$()

Return Namegen$() + " " + Namegen$()

End Function
Function Namegen$()
NameLength = Rand(4,8)
Local Letter$[12]
For loop = 1 To namelength
char = Rand(1,26)

Select char
Case 1
Letter[Loop] = "a"
Vowel = Vowel + 1
Case 2
Letter[Loop] = "b"
Case 3
Letter[Loop] = "c"
Case 4
Letter[Loop] = "d"
Case 5
Letter[Loop] = "e"
Vowel = Vowel + 1
Case 6
Letter[Loop] = "f"
Case 7
Letter[Loop] = "g"
Case 8
Letter[Loop] = "h"
Case 9
Letter[Loop] = "i"
Vowel = Vowel + 1
Case 10
Letter[Loop] = "j"
Case 11
Letter[Loop] = "k"
Case 12
Letter[Loop] = "l"
Case 13
Letter[Loop] = "m"
Case 14
Letter[Loop] = "n"
Case 15
Letter[Loop] = "o"
Vowel = Vowel + 1
Case 16
Letter[Loop] = "p"
Case 17
Letter[Loop] = "q"
Case 18
Letter[Loop] = "r"
Case 19
Letter[Loop] = "s"
Case 20
Letter[Loop] = "t"
Case 21
Letter[Loop] = "u"
Vowel = Vowel + 1
Case 22
Letter[Loop] = "v"
Case 23
Letter[Loop] = "w"
Case 24
Letter[Loop] = "x"
Case 25
Letter[Loop] = "y"
Vowel = Vowel + 1
Case 26
Letter[Loop] = "z"
End Select



If Vowel < Ceil(loop/2) Letter[Loop] = Re_vowel$() Vowel = Vowel + 1
If Loop = 1 Letter[Loop] = Upper$(Letter[Loop])
Name$ = name + Letter[Loop]
Next

Return Name
End Function


Function Re_vowel$()
Numb = Rand(1,64)
If Numb > 0 And Numb <= 16 Return "a"
If Numb > 16 And Numb <= 34 Return "e"
If Numb > 34 And Numb <= 46 Return "i"
If Numb > 46 And Numb <= 56 Return "o"
If Numb > 56 And Numb <= 62 Return "u"
If Numb > 62 Return "y"
End Function


Function FPS()

FramesPerSecond# = MilliSecs() - FrameCount
FrameCount = MilliSecs()

Return 1000 / FramesPerSecond
End Function




Function DeadTarget()
For Loop = 1 To Number_of_Enemies
If NPCDead(Loop) = 0
If NPCDead(NPCPrey(Loop)) = 1 NPCPrey(Loop) = 0 
EndIf
Next
End Function



Function ChooseTarget()

For Loop = 1 To Number_Of_Enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop) = 0
For Loop2 = 1 To Number_Of_Enemies + 1
If NPCDead(Loop2) = 0
If Not Loop = Loop2
If JRAILib_Engage(NPC(Loop),80,NPC(Loop2),500) NPCPrey(Loop) = Loop2
EndIf
EndIf
Next
EndIf
EndIf
Next

End Function


Function Attack()
For Loop = 1 To Number_Of_Enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop)> 0 TurnEntity NPC(Loop),0,JRAILib_Orient#(NPC(Loop),NPC(NPCPrey(Loop)),5,1,9),0
EndIf
Next
End Function 



Function JRAILib_Orient#(JRAILib_Source,JRAILib_Recipient,JRAILib_Speed#,JRAILib_ReducedSpeed#,JRAILib_ReducedDistance#)
JRAILib_DeltaPitch# = DeltaYaw#(JRAILib_Source,JRAILib_Recipient)


If Abs(JRAILib_DeltaPitch) <= JRAILib_ReducedSpeed Return JRAILib_Pitch# + JRAILib_DeltaPitch

If Abs(JRAILib_DeltaPitch) > JRAILib_ReducedDistance
JRAILib_PitchChangeAmount# = JRAILib_Speed
Else
JRAILib_PitchChangeAmount# = JRAILib_ReducedSpeed
EndIf
If JRAILib_DeltaPitch# < 0 JRAILib_PitchChangeAmount# = JRAILib_PitchChangeAmount# * -1



Return JRAILib_PitchChangeAmount#
 
End Function
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Function JRAILib_Engage(JRAILib_Hunter,JRAILib_BowlOfVision,JRAILib_Prey,JRAILib_SightRange)
JRAILib_DeltaPitch = DeltaYaw#(JRAILib_Hunter,JRAILib_Prey)
If Abs(JRAILib_DeltaPitch) <= JRAILib_BowlOfVision And EntityDistance(JRAILib_Hunter,JRAILib_Prey) <= JRAILib_SightRange And EntityVisible(JRAILib_Hunter,JRAILib_Prey)
Return 1
Else
Return 0
EndIf
End Function

Function GameOver(Murderer$)
ClsColor 128,0,0
Cls
Text CenterX,0,"You were gunned down by " + Murderer,1,0
Flip
Repeat
Until KeyHit(1)
End
End Function
Function Kill(Victim$)
Writing = "You Killed " + Victim
End Function




Controls are arrow keys to move around, and LMB to fire

You have to wait until you are told that you can fight, then you must shoot all the enemies before they shoot you.

Please comment.

The movement via arrow keys is messed up.
up = right move
right = down move
down = left move
left = up move

Are you sure about that? It works fine for me.

AppTitle "3d Shooter"
Graphics3D 800,600,0,1
SeedRnd MilliSecs()
Const Number_of_enemies = 10
Global CenterX = GraphicsWidth()/2
Global CenterY = GraphicsHeight()/2
Global Abort = 0
Global FrameCount = MilliSecs()
Global Camera = CreateCamera()
Global Truce = 10000
Global DoFPS
Global Writing$ = "Press Enter to view FPS"
;assemble the player
Global CloneMe = CreatePivot()
Global Player = CreateCylinder()
EntityParent Player,CloneMe
EntityColor Player,0,0,255
Global XLook
Eyes = CreateImage(16,16)
SetBuffer ImageBuffer(Eyes)
Color 255,255,0
Rect 0,0,16,16
Color 255,0,0
Plot 4,8
Plot 12,8
Global FPSCalc = 0
TranslateEntity CloneMe,0,-7,1
TranslateEntity Camera,0,-3,1
ScaleMesh Player,1,3,1
Gun = CreateCylinder()
EntityParent Gun,CloneMe
PositionEntity Gun,0,2,2
ScaleMesh Gun,0.25,2,0.25
RotateEntity Gun,90,0,0
EntityColor gun,64,32,0
Sight = CreateCube()
ScaleMesh Sight,0.0125,0.1,0.1
EntityColor Sight,0,0,0
HeadTexture = CreateTexture(64,64)
SetBuffer TextureBuffer(HeadTexture)
Color 255,255,0
Rect 0,0,64,64
DrawImage Eyes,8,16
Global Grass = CreateTexture(32,32)
Global Light = CreateLight(2)
LightColor Light,10,10,10
EntityParent Light,Camera
Global Head = CreateSphere()
RotateEntity Head,0,-90,0
EntityParent Head,CloneMe
EntityParent Sight,CloneMe
PositionEntity Sight,0,2.25,3.75
EntityTexture Head,HeadTexture
PositionEntity Head,0,4,0
SetBuffer TextureBuffer(Grass);Make grass texture

Color 0,255,0
Rect 0,0,16,16
Rect 16,16,16,16
Color 0,250,0
Rect 16,0,16,16
Rect 0,16,16,16
SetBuffer BackBuffer()
EntityType CloneMe,17
EntityRadius CloneMe,3
EntityPickMode CloneMe,1
;done...
;make bullet
Bullet = CreateCylinder()
RotateEntity Bullet,90,0,0
ScaleMesh Bullet,0.125,150,0.125
EntityColor Bullet,255,255,16
Target = CreatePivot()
;RotateEntity Target,90,0,0
Color 255,128,0
;done...
;Build Enemies
Dim NPC(Number_of_enemies + 1)
Dim NPCName$(Number_of_enemies)
Dim NPCPrey(Number_of_enemies + 1)
Dim NPCDead(Number_of_enemies + 1)
Dim NPCInjurePoint(Number_of_enemies + 1)
Dim NPCFiredShot(Number_of_enemies + 1)
Dim NPCDirection(Number_of_enemies)
Dim NPCTime(Number_of_enemies)
Dim NPCGunshot(Number_of_enemies + 1)
Dim NPCInaccuracy#(Number_of_enemies + 1)
Dim NPCFiringDelay(Number_of_enemies + 1)
For loop = 1 To Number_of_enemies
	NPCName(Loop) = Rename$()
	NPC(Loop) = CopyEntity(CloneMe)
	NPCGunshot(Loop) = CopyEntity(Bullet)
	NPCInjurePoint(Loop) = CopyEntity(Target)
	NPCInaccuracy(Loop) = Rnd(5,15)
	EntityParent NPCInjurePoint(Loop),NPC(Loop)
	PositionEntity NPCInjurePoint(Loop),0,2,1
	HideEntity NPCGunshot(Loop)
	EntityParent NPCGunshot(Loop),NPC(Loop)
	PositionEntity NPCGunshot(Loop),0,2,150
	NPCDirection(Loop) = Rnd(-1,1)
	NPCTime(Loop) = Rand(1,100)
Next


NPC(Number_of_enemies + 1) = CopyEntity(CloneMe)
NPCGunshot(Loop) = CopyEntity(Bullet)
EntityParent NPCGunshot(Number_of_enemies + 1),NPC(Number_of_enemies + 1)
PositionEntity NPCGunshot(Number_of_enemies + 1),0,2,150
NPCInaccuracy(Number_of_enemies + 1) = Rnd(5,15)
HideEntity NPCGunshot(Number_of_enemies + 1)

NPCInjurePoint(Number_of_enemies + 1) = CopyEntity(Target)
EntityParent NPCInjurePoint(Number_of_enemies + 1),NPC(Number_of_enemies + 1)
PositionEntity NPCInjurePoint(Number_of_enemies + 1),0,2,1

HideEntity CloneMe
HideEntity Bullet
HideEntity Target

EntityParent Camera,NPC(Number_of_enemies + 1)
Collisions 17,17,1,2

Global Ground = CreatePlane()
EntityTexture Ground,Grass
TranslateEntity Ground,0,-10,0
Runtime()
End

Function Runtime();Runtime function
	Repeat
		Timer = MilliSecs()
		UpdateNPCs()
		MouseLook()
		If Truce = 0 Then Gunshot()
		TurnEntity NPC(Number_of_enemies + 1),0,-XLook/5,0
		MoveEntity NPC(Number_of_enemies + 1),KeyDown(205) - KeyDown(203),0,KeyDown(200) * 2 - KeyDown(208)
		UpdateWorld()
		RenderWorld()
		If KeyDown(28) Then Text CenterX,10,"FPS:",1,0
		If KeyDown(28) Then Text CenterX,20,FPS(),1,0
		Text CenterX,0,Writing,1,0
		Flip
		If KeyHit(1) Then Abort = 1
		While Not MilliSecs() - Timer > 25
		Wend
	Until Abort = 1
End Function

Function MouseLook()
	XLook = MouseX() - CenterX
	MoveMouse CenterX,CenterY
End Function

Function UpdateNPCs()
	For Loop = 1 To Number_of_enemies
		If NPCDead(Loop) = 0 Then
			NPCTime(Loop) = NPCTime(Loop) - 1
			If NPCTime(Loop) < 1 Then
				NPCTime(Loop) = Rand(1,100)
				NPCDirection(Loop) = Rnd(-1,1)
			EndIf
			If NPCPrey(Loop) = 0 Then TurnEntity NPC(Loop),0,NPCDirection(Loop),0
				
			If Truce > 0 Then
				Truce = Truce - 1
				If Truce = 0 Then Writing = "Let the killing begin!"
				FlushMouse
			Else
				ChooseTarget()
				Attack()
				DeadTarget()
			EndIf
			If NPCPrey(Loop) = 0 Then
				MoveEntity NPC(Loop),0,0,1
			ElseIf NPCDead(NPCPrey(Loop)) = 0 Then
				If EntityDistance(NPC(Loop),NPC(NPCPrey(Loop))) > 250 Then MoveEntity NPC(Loop),0,0,1
			EndIf
		EndIf
	Next
End Function

Function Gunshot()
	If MouseHit(1) Then NPCFiredShot(Number_of_enemies + 1) = 1
		
	For Loop = 1 To Number_of_enemies
		If NPCDead(Loop) = 0
			If NPCPrey(Loop) > 0
				If NPCDead(NPCPrey(Loop)) = 0
					NPCFiringDelay(Loop) = NPCFiringDelay(Loop) - 1
					If NPCFiringDelay(Loop) <= 0
						If EntityDistance(NPC(Loop),NPC(NPCPrey(Loop))) < 285
							NPCFiredShot(Loop) = 1
							NPCFiringDelay(Loop) = Rnd(30,40)
						EndIf
					EndIf
				EndIf
			EndIf
		EndIf
	Next
		
	For Loop = 1 To Number_of_enemies + 1
		If NPCDead(Loop) = 0 Then
			If NPCFiredShot(Loop) = 1 Then
				TurnEntity NPC(Loop),0,Rnd(-NPCInaccuracy(Loop),NPCInaccuracy(Loop)),0
				ShowEntity NPCGunshot(Loop)
				
				DeleteEntity% = EntityPick(NPCInjurePoint(Loop),300)
				NPCFiredShot(Loop) = 2
			ElseIf NPCFiredShot(Loop) = 2 Then
				NPCFiredShot(Loop) = 0
				HideEntity NPCGunshot(Loop)
			EndIf
		EndIf
		
		For Loop2 = 1 To Number_of_enemies + 1
			
			If NPC(Loop2) = DeleteEntity% Then
				If NPCDead(Loop2) = 0 Then
					FreeEntity NPC(Loop2)
;NPC(Loop2) = 0
					NPCDead(Loop2) = 1
					If Loop2 = Number_of_enemies + 1 Then GameOver(NPCName(Loop))
					If Loop = Number_of_enemies + 1 Then Kill(NPCName(Loop2))
				EndIf
			EndIf
		Next
	Next
;	Is An NPC Dead
				
End Function

Function Rename$()
	Return Namegen$() + " " + Namegen$()
End Function

Function Namegen$()
	NameLength = Rand(4,8)
	Local Letter$[12]
	For loop = 1 To namelength
		char = Rand(1,26)
		
		Select char
			Case 1 : Letter[Loop] = "a" : Vowel = Vowel + 1
			Case 2 : Letter[Loop] = "b" 
			Case 3 : Letter[Loop] = "c"
			Case 4 : Letter[Loop] = "d"
			Case 5 : Letter[Loop] = "e" : Vowel = Vowel + 1
			Case 6 : Letter[Loop] = "f"
			Case 7 : Letter[Loop] = "g"
			Case 8 : Letter[Loop] = "h"
			Case 9 : Letter[Loop] = "i" : Vowel = Vowel + 1
			Case 10 : Letter[Loop] = "j"
			Case 11 : Letter[Loop] = "k"
			Case 12 : Letter[Loop] = "l"
			Case 13 : Letter[Loop] = "m"
			Case 14 : Letter[Loop] = "n"
			Case 15 : Letter[Loop] = "o" : Vowel = Vowel + 1
			Case 16 : Letter[Loop] = "p"
			Case 17 : Letter[Loop] = "q"
			Case 18 : Letter[Loop] = "r"
			Case 19 : Letter[Loop] = "s"
			Case 20 : Letter[Loop] = "t"
			Case 21 : Letter[Loop] = "u" : Vowel = Vowel + 1
			Case 22 : Letter[Loop] = "v"
			Case 23 : Letter[Loop] = "w"
			Case 24 : Letter[Loop] = "x"
			Case 25 : Letter[Loop] = "y" : Vowel = Vowel + 1
			Case 26 : Letter[Loop] = "z"
		End Select
		
		If Vowel < Ceil(loop/2) Then Letter[Loop] = Re_vowel$() Vowel = Vowel + 1
		If Loop = 1 Then Letter[Loop] = Upper$(Letter[Loop])
		Name$ = name + Letter[Loop]
	Next
			
	Return Name
End Function

Function Re_vowel$()
	Numb = Rand(1,64)
	If Numb > 0 And Numb <= 16 Then Return "a"
	If Numb > 16 And Numb <= 34 Then Return "e"
	If Numb > 34 And Numb <= 46 Then Return "i"
	If Numb > 46 And Numb <= 56 Then Return "o"
	If Numb > 56 And Numb <= 62 Then Return "u"
	If Numb > 62 Then Return "y"
End Function

Function FPS()
	FramesPerSecond# = MilliSecs() - FrameCount
	FrameCount = MilliSecs()
	Return 1000 / FramesPerSecond
End Function

Function DeadTarget()
	For Loop = 1 To Number_of_enemies
		If NPCDead(Loop) = 0 Then 
			If NPCDead(NPCPrey(Loop)) = 1 Then NPCPrey(Loop) = 0 
		EndIf
	Next
End Function

Function ChooseTarget()
	For Loop = 1 To Number_of_enemies
		If NPCDead(Loop) = 0 Then
			If NPCPrey(Loop) = 0 Then
				For Loop2 = 1 To Number_of_enemies + 1
					If NPCDead(Loop2) = 0 Then
						If Not Loop = Loop2 Then
							If JRAILib_Engage(NPC(Loop),80,NPC(Loop2),500) NPCPrey(Loop) = Loop2
							EndIf
						EndIf
					Next
				EndIf
			EndIf
		Next
End Function

Function Attack()
	For Loop = 1 To Number_of_enemies
		If NPCDead(Loop) = 0 Then
			If NPCPrey(Loop)> 0 Then TurnEntity NPC(Loop),0,JRAILib_Orient#(NPC(Loop),NPC(NPCPrey(Loop)),5,1,9),0
		EndIf
	Next
End Function 

Function JRAILib_Orient#(JRAILib_Source,JRAILib_Recipient,JRAILib_Speed#,JRAILib_ReducedSpeed#,JRAILib_ReducedDistance#)
	JRAILib_DeltaPitch# = DeltaYaw#(JRAILib_Source,JRAILib_Recipient)
	
	If Abs(JRAILib_DeltaPitch) <= JRAILib_ReducedSpeed Then Return JRAILib_Pitch# + JRAILib_DeltaPitch
		
	If Abs(JRAILib_DeltaPitch) > JRAILib_ReducedDistance Then
		JRAILib_PitchChangeAmount# = JRAILib_Speed
	Else
		JRAILib_PitchChangeAmount# = JRAILib_ReducedSpeed
	EndIf
	If JRAILib_DeltaPitch# < 0 Then JRAILib_PitchChangeAmount# = JRAILib_PitchChangeAmount# * -1
	Return JRAILib_PitchChangeAmount#
			
End Function
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Function JRAILib_Engage(JRAILib_Hunter,JRAILib_BowlOfVision,JRAILib_Prey,JRAILib_SightRange)
	JRAILib_DeltaPitch = DeltaYaw#(JRAILib_Hunter,JRAILib_Prey)
	If Abs(JRAILib_DeltaPitch) <= JRAILib_BowlOfVision And EntityDistance(JRAILib_Hunter,JRAILib_Prey) <= JRAILib_SightRange And EntityVisible(JRAILib_Hunter,JRAILib_Prey)
		Return 1
	Else
		Return 0
	EndIf
End Function

Function GameOver(Murderer$)
	ClsColor 128,0,0
	Cls
	Text CenterX,0,"You were gunned down by " + Murderer,1,0
	Flip
	Repeat
	Until KeyHit(1)
	End
End Function

Function Kill(Victim$)
	Writing = "You Killed " + Victim
End Function


Cleaned up the code a bit. Same code thoe, just more readable :P

AppTitle "3d Shooter"
Graphics3D 800,600,0,1
SeedRnd MilliSecs()
Const Number_of_enemies = 10
Global CenterX = GraphicsWidth()/2
Global CenterY = GraphicsHeight()/2
Global Abort = 0
Global FrameCount = MilliSecs()
Global Camera = CreateCamera()
CameraRange Camera,1,10000
Global Truce = 5000
Global DoFPS
Global Writing$ = "Press Enter to view FPS"
;assemble the player
Global CloneMe = CreatePivot()
Global Player = CreateCylinder()
EntityParent Player,CloneMe
EntityColor Player,0,0,255
Global XLook
Eyes = CreateImage(16,16)
SetBuffer ImageBuffer(Eyes)
Color 255,255,0
Rect 0,0,16,16
Color 255,0,0
Plot 4,8
Plot 12,8
Global FPSCalc = 0
TranslateEntity CloneMe,0,-7,1
TranslateEntity Camera,0,-3,1
ScaleMesh Player,1,3,1
Gun = CreateCylinder()
EntityParent Gun,CloneMe
PositionEntity Gun,0,2,2
ScaleMesh Gun,0.25,2,0.25
RotateEntity Gun,90,0,0
EntityColor gun,64,32,0
Sight = CreateCube()
ScaleMesh Sight,0.0125,0.1,0.1
EntityColor Sight,0,0,0
HeadTexture = CreateTexture(64,64)
SetBuffer TextureBuffer(HeadTexture)
Color 255,255,0
Rect 0,0,64,64
DrawImage Eyes,8,16
Global Grass = CreateTexture(32,32)
Global Light = CreateLight(2)
LightColor Light,10,10,10
EntityParent Light,Camera
Global Head = CreateSphere()
RotateEntity Head,0,-90,0
EntityParent Head,CloneMe
EntityParent Sight,CloneMe
PositionEntity Sight,0,2.25,3.75
EntityTexture Head,HeadTexture
PositionEntity Head,0,4,0
SetBuffer TextureBuffer(Grass);Make grass texture

Color 0,255,0
Rect 0,0,16,16
Rect 16,16,16,16
Color 0,250,0
Rect 16,0,16,16
Rect 0,16,16,16
SetBuffer BackBuffer()
EntityType CloneMe,17
EntityRadius CloneMe,3
EntityPickMode CloneMe,1
;done...
;make bullet
Bullet = CreateCylinder()
RotateEntity Bullet,90,0,0
ScaleMesh Bullet,0.125,150,0.125
EntityColor Bullet,255,255,16
Target = CreatePivot()
;RotateEntity Target,90,0,0
Blood = CreateCylinder()
ScaleMesh Blood,5,.001,5
EntityColor Blood,160,0,0
Color 255,128,0
;done...
;Build Enemies
Dim NPC(Number_of_enemies + 1)
Dim NPCBlood(Number_of_enemies)
Dim NPCName$(Number_of_enemies)
Dim NPCPrey(Number_of_enemies + 1)
Dim NPCDead(Number_of_enemies + 1)
Dim NPCInjurePoint(Number_of_enemies + 1)
Dim NPCFiredShot(Number_of_enemies + 1)
Dim NPCDirection(Number_of_enemies)
Dim NPCTime(Number_of_enemies)
Dim NPCGunshot(Number_of_enemies + 1)
Dim NPCInaccuracy#(Number_of_enemies + 1)
Dim NPCFiringDelay(Number_of_enemies + 1)
For loop = 1 To Number_of_enemies
NPCName(Loop) = Rename$()
NPC(Loop) = CopyEntity(CloneMe)
NPCGunshot(Loop) = CopyEntity(Bullet)
NPCInjurePoint(Loop) = CopyEntity(Target)
NPCInaccuracy(Loop) = Rnd(5,15)
NPCBlood(Loop) = CopyEntity(Blood)
HideEntity NPCBlood(Loop)
EntityParent NPCInjurePoint(Loop),NPC(Loop)
PositionEntity NPCInjurePoint(Loop),0,2,1
HideEntity NPCGunshot(Loop)
EntityParent NPCGunshot(Loop),NPC(Loop)
PositionEntity NPCGunshot(Loop),0,2,150
NPCDirection(Loop) = Rnd(-1,1)
NPCTime(Loop) = Rand(1,100)
Next


NPC(Number_of_enemies + 1) = CopyEntity(CloneMe)
NPCGunshot(Loop) = CopyEntity(Bullet)
EntityParent NPCGunshot(Number_of_enemies + 1),NPC(Number_of_enemies + 1)
PositionEntity NPCGunshot(Number_of_enemies + 1),0,2,150
NPCInaccuracy(Number_of_enemies + 1) = Rnd(5,15)
HideEntity NPCGunshot(Number_of_enemies + 1)

NPCInjurePoint(Number_of_enemies + 1) = CopyEntity(Target)
EntityParent NPCInjurePoint(Number_of_enemies + 1),NPC(Number_of_enemies + 1)
PositionEntity NPCInjurePoint(Number_of_enemies + 1),0,2,1




HideEntity Blood
HideEntity CloneMe
HideEntity Bullet
HideEntity Target

EntityParent Camera,NPC(Number_of_enemies + 1)



Collisions 17,17,1,2







Global Ground = CreatePlane()
EntityTexture Ground,Grass
TranslateEntity Ground,0,-10,0


Runtime()
End




Function Runtime();Runtime function

Repeat
Timer = MilliSecs()



UpdateNPCs()
MouseLook()
If Truce = 0 GunShot()
TurnEntity NPC(Number_of_enemies + 1),0,-Xlook/5,0
MoveEntity NPC(Number_of_enemies + 1),KeyDown(205) - KeyDown(203),0,KeyDown(200) * 2 - KeyDown(208)
UpdateWorld()
RenderWorld()
If KeyDown(28) Text CenterX,10,"FPS:",1,0
If KeyDown(28) Text CenterX,20,FPS(),1,0
Text CenterX,0,Writing,1,0
Flip


If KeyHit(1) Abort = 1


While Not MilliSecs() - Timer > 25
Wend
Until Abort = 1

End Function

Function MouseLook()

Xlook = MouseX() - CenterX
MoveMouse CenterX,CenterY
End Function



Function UpdateNPCs()
For Loop = 1 To Number_of_enemies
If NPCDead(Loop) = 0
NPCTime(Loop) = NPCTime(Loop) - 1
If NPCTime(Loop) < 1
NPCTime(Loop) = Rand(1,100)
NPCDirection(Loop) = Rnd(-1,1)
EndIf
If NPCPrey(Loop) = 0 TurnEntity NPC(Loop),0,NPCDirection(Loop),0

If Truce > 0
Truce = Truce - 1
If Truce = 0 Writing = "Let the killing begin!"
FlushMouse
Else
ChooseTarget()
Attack()
DeadTarget()
EndIf
If NPCPrey(Loop) = 0
MoveEntity NPC(Loop),0,0,1
ElseIf NPCDead(NPCPrey(Loop)) = 0
If EntityDistance(NPC(Loop),NPC(NPCPrey(Loop))) > 250 MoveEntity NPC(Loop),0,0,1
EndIf
EndIf
Next
End Function





;Function









Function Gunshot()


If MouseHit(1) NPCFiredShot(Number_of_enemies + 1) = 1








For Loop = 1 To Number_of_enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop) > 0
If NPCDead(NPCPrey(Loop)) = 0
NPCFiringDelay(Loop) = NPCFiringDelay(Loop) - 1
If NPCFiringDelay(Loop) <= 0
If EntityDistance(NPC(Loop),NPC(NPCPrey(Loop))) < 285
NPCFiredShot(Loop) = 1
NPCFiringDelay(Loop) = Rnd(30,40)
EndIf
EndIf
EndIf
EndIf
EndIf
Next





For Loop = 1 To Number_of_enemies + 1
If NPCDead(Loop) = 0
If NPCFiredShot(Loop) = 1
TurnEntity NPC(Loop),0,Rnd(-NPCInaccuracy(Loop),NPCInaccuracy(Loop)),0
ShowEntity NPCGunshot(Loop)

DeleteEntity% = EntityPick(NPCInjurePoint(Loop),300)
NPCFiredShot(Loop) = 2
ElseIf NPCFiredShot(Loop) = 2
NPCFiredShot(Loop) = 0
HideEntity NPCGunshot(Loop)
EndIf
EndIf

For Loop2 = 1 To Number_of_Enemies + 1

If NPC(Loop2) = DeleteEntity%
If NPCDead(Loop2) = 0
If Loop2 = Number_of_Enemies + 1 GameOver(NPCName(Loop))
PositionEntity NPCBlood(Loop2),EntityX(NPC(Loop2)),-10,EntityZ(NPC(Loop2))
FreeEntity NPC(Loop2)
;NPC(Loop2) = 0
NPCDead(Loop2) = 1
ShowEntity NPCBlood(Loop2)
If Loop = Number_of_Enemies + 1 Kill(NPCName(Loop2))
EndIf
EndIf
Next
Next


;Is An NPC Dead

End Function













Function Rename$()

Return Namegen$() + " " + Namegen$()

End Function
Function Namegen$()
NameLength = Rand(4,8)
Local Letter$[12]
For loop = 1 To namelength
char = Rand(1,26)

Select char
Case 1
Letter[Loop] = "a"
Vowel = Vowel + 1
Case 2
Letter[Loop] = "b"
Case 3
Letter[Loop] = "c"
Case 4
Letter[Loop] = "d"
Case 5
Letter[Loop] = "e"
Vowel = Vowel + 1
Case 6
Letter[Loop] = "f"
Case 7
Letter[Loop] = "g"
Case 8
Letter[Loop] = "h"
Case 9
Letter[Loop] = "i"
Vowel = Vowel + 1
Case 10
Letter[Loop] = "j"
Case 11
Letter[Loop] = "k"
Case 12
Letter[Loop] = "l"
Case 13
Letter[Loop] = "m"
Case 14
Letter[Loop] = "n"
Case 15
Letter[Loop] = "o"
Vowel = Vowel + 1
Case 16
Letter[Loop] = "p"
Case 17
Letter[Loop] = "q"
Case 18
Letter[Loop] = "r"
Case 19
Letter[Loop] = "s"
Case 20
Letter[Loop] = "t"
Case 21
Letter[Loop] = "u"
Vowel = Vowel + 1
Case 22
Letter[Loop] = "v"
Case 23
Letter[Loop] = "w"
Case 24
Letter[Loop] = "x"
Case 25
Letter[Loop] = "y"
Vowel = Vowel + 1
Case 26
Letter[Loop] = "z"
End Select



If Vowel < Ceil(loop/2) Letter[Loop] = Re_vowel$() Vowel = Vowel + 1
If Loop = 1 Letter[Loop] = Upper$(Letter[Loop])
Name$ = name + Letter[Loop]
Next

Return Name
End Function


Function Re_vowel$()
Numb = Rand(1,64)
If Numb > 0 And Numb <= 16 Return "a"
If Numb > 16 And Numb <= 34 Return "e"
If Numb > 34 And Numb <= 46 Return "i"
If Numb > 46 And Numb <= 56 Return "o"
If Numb > 56 And Numb <= 62 Return "u"
If Numb > 62 Return "y"
End Function


Function FPS()

FramesPerSecond# = MilliSecs() - FrameCount
FrameCount = MilliSecs()

Return 1000 / FramesPerSecond
End Function




Function DeadTarget()
For Loop = 1 To Number_of_Enemies
If NPCDead(Loop) = 0
If NPCDead(NPCPrey(Loop)) = 1 NPCPrey(Loop) = 0 
EndIf
Next
End Function



Function ChooseTarget()

For Loop = 1 To Number_Of_Enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop) = 0
For Loop2 = 1 To Number_Of_Enemies + 1
If NPCDead(Loop2) = 0
If Not Loop = Loop2
If JRAILib_Engage(NPC(Loop),80,NPC(Loop2),500) NPCPrey(Loop) = Loop2
EndIf
EndIf
Next
EndIf
EndIf
Next

End Function


Function Attack()
For Loop = 1 To Number_Of_Enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop)> 0 TurnEntity NPC(Loop),0,JRAILib_Orient#(NPC(Loop),NPC(NPCPrey(Loop)),5,1,9),0
EndIf
Next
End Function 



Function JRAILib_Orient#(JRAILib_Source,JRAILib_Recipient,JRAILib_Speed#,JRAILib_ReducedSpeed#,JRAILib_ReducedDistance#)
JRAILib_DeltaPitch# = DeltaYaw#(JRAILib_Source,JRAILib_Recipient)


If Abs(JRAILib_DeltaPitch) <= JRAILib_ReducedSpeed Return JRAILib_Pitch# + JRAILib_DeltaPitch

If Abs(JRAILib_DeltaPitch) > JRAILib_ReducedDistance
JRAILib_PitchChangeAmount# = JRAILib_Speed
Else
JRAILib_PitchChangeAmount# = JRAILib_ReducedSpeed
EndIf
If JRAILib_DeltaPitch# < 0 JRAILib_PitchChangeAmount# = JRAILib_PitchChangeAmount# * -1



Return JRAILib_PitchChangeAmount#
 
End Function
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Function JRAILib_Engage(JRAILib_Hunter,JRAILib_BowlOfVision,JRAILib_Prey,JRAILib_SightRange)
JRAILib_DeltaPitch = DeltaYaw#(JRAILib_Hunter,JRAILib_Prey)
If Abs(JRAILib_DeltaPitch) <= JRAILib_BowlOfVision And EntityDistance(JRAILib_Hunter,JRAILib_Prey) <= JRAILib_SightRange And EntityVisible(JRAILib_Hunter,JRAILib_Prey)
Return 1
Else
Return 0
EndIf
End Function

Function GameOver(Murderer$)
ClsColor 128,0,0
Cls
Text CenterX,0,"You were gunned down by " + Murderer,1,0
Flip
Repeat
Until KeyHit(1)
End
End Function
Function Kill(Victim$)
Writing = "You Killed " + Victim
End Function

Added Blood.

AppTitle "3d Shooter"
Graphics3D 800,600,0,1
SeedRnd MilliSecs()
Const Number_of_enemies = 10
Global CenterX = GraphicsWidth()/2
Global CenterY = GraphicsHeight()/2
Global Abort = 0
Global FrameCount = MilliSecs()
Global Camera = CreateCamera()
CameraRange Camera,1,10000
Global Truce = 500 * Number_of_enemies
Global DoFPS
Global Writing$ = "Press Enter to view FPS"
;assemble the player
Global CloneMe = CreatePivot()
Global Player = CreateCylinder()
EntityParent Player,CloneMe
EntityColor Player,0,0,255
Global XLook
Eyes = CreateImage(16,16)
SetBuffer ImageBuffer(Eyes)
Color 200,155,45
Rect 0,0,16,16
Color 64,32,0
Plot 4,8
Plot 12,8
Global FPSCalc = 0
TranslateEntity CloneMe,0,-7,1
TranslateEntity Camera,0,-3,1
ScaleMesh Player,1,3,1
Gun = CreateCylinder()
EntityParent Gun,CloneMe
PositionEntity Gun,0,2,2
ScaleMesh Gun,0.25,2,0.25
RotateEntity Gun,90,0,0
EntityColor gun,64,32,0
Sight = CreateCube()
ScaleMesh Sight,0.0125,0.1,0.1
EntityColor Sight,0,0,0
HeadTexture = CreateTexture(64,64)
SetBuffer TextureBuffer(HeadTexture)
Color 200,155,45
Rect 0,0,64,64
DrawImage Eyes,8,16
Global Grass = CreateTexture(32,32)
Global Light = CreateLight(2)
LightColor Light,10,10,10
EntityParent Light,Camera
Global Head = CreateSphere()
Global Turban = CreateSphere()
RotateEntity Head,0,-90,0
EntityParent Head,CloneMe
EntityParent Turban,CloneMe
EntityColor Turban,230,230,230
ScaleMesh Turban,1.25,0.75,1.25
EntityParent Sight,CloneMe
PositionEntity Sight,0,2.25,3.75
EntityTexture Head,HeadTexture
PositionEntity Head,0,4,0
PositionEntity Turban,0,5,0
SetBuffer TextureBuffer(Grass);Make grass texture

Color 0,255,0
Rect 0,0,16,16
Rect 16,16,16,16
Color 0,250,0
Rect 16,0,16,16
Rect 0,16,16,16
SetBuffer BackBuffer()
EntityType CloneMe,17
EntityRadius CloneMe,3
EntityPickMode CloneMe,1
;done...
;make bullet
Bullet = CreateCylinder()
RotateEntity Bullet,90,0,0
ScaleMesh Bullet,0.125,150,0.125
EntityColor Bullet,255,255,16
Target = CreatePivot()
;RotateEntity Target,90,0,0
Blood = CreateCylinder()
ScaleMesh Blood,5,.001,5
EntityColor Blood,160,0,0
Color 255,128,0
;done...
;Build Enemies
Dim NPC(Number_of_enemies + 1)
Dim NPCBlood(Number_of_enemies)
Dim NPCName$(Number_of_enemies)
Dim NPCPrey(Number_of_enemies + 1)
Dim NPCDead(Number_of_enemies + 1)
Dim NPCInjurePoint(Number_of_enemies + 1)
Dim NPCFiredShot(Number_of_enemies + 1)
Dim NPCDirection(Number_of_enemies)
Dim NPCTime(Number_of_enemies)
Dim NPCGunshot(Number_of_enemies + 1)
Dim NPCInaccuracy#(Number_of_enemies + 1)
Dim NPCFiringDelay(Number_of_enemies + 1)
For loop = 1 To Number_of_enemies
NPCName(Loop) = Rename$()
NPC(Loop) = CopyEntity(CloneMe)
NPCGunshot(Loop) = CopyEntity(Bullet)
NPCInjurePoint(Loop) = CopyEntity(Target)
NPCInaccuracy(Loop) = Rnd(5,15)
NPCBlood(Loop) = CopyEntity(Blood)
HideEntity NPCBlood(Loop)
EntityParent NPCInjurePoint(Loop),NPC(Loop)
PositionEntity NPCInjurePoint(Loop),0,2,1
HideEntity NPCGunshot(Loop)
EntityParent NPCGunshot(Loop),NPC(Loop)
PositionEntity NPCGunshot(Loop),0,2,150
NPCDirection(Loop) = Rnd(-1,1)
NPCTime(Loop) = Rand(1,100)
Next


NPC(Number_of_enemies + 1) = CopyEntity(CloneMe)
NPCGunshot(Loop) = CopyEntity(Bullet)
EntityParent NPCGunshot(Number_of_enemies + 1),NPC(Number_of_enemies + 1)
PositionEntity NPCGunshot(Number_of_enemies + 1),0,2,150
NPCInaccuracy(Number_of_enemies + 1) = Rnd(5,15)
HideEntity NPCGunshot(Number_of_enemies + 1)

NPCInjurePoint(Number_of_enemies + 1) = CopyEntity(Target)
EntityParent NPCInjurePoint(Number_of_enemies + 1),NPC(Number_of_enemies + 1)
PositionEntity NPCInjurePoint(Number_of_enemies + 1),0,2,1




HideEntity Blood
HideEntity CloneMe
HideEntity Bullet
HideEntity Target
HideEntity Turban

EntityParent Camera,NPC(Number_of_enemies + 1)



Collisions 17,17,1,2







Global Ground = CreatePlane()
EntityTexture Ground,Grass
TranslateEntity Ground,0,-10,0


Runtime()
End




Function Runtime();Runtime function

Repeat
Timer = MilliSecs()



UpdateNPCs()
MouseLook()
If Truce = 0 GunShot()
TurnEntity NPC(Number_of_enemies + 1),0,-Xlook/5,0
MoveEntity NPC(Number_of_enemies + 1),KeyDown(205) - KeyDown(203),0,KeyDown(200) * 2 - KeyDown(208)
UpdateWorld()
RenderWorld()
If KeyDown(28) Text CenterX,10,"FPS:",1,0
If KeyDown(28) Text CenterX,20,FPS(),1,0
Text CenterX,0,Writing,1,0
Flip


If KeyHit(1) Abort = 1


While Not MilliSecs() - Timer > 25
Wend
Until Abort = 1

End Function

Function MouseLook()

Xlook = MouseX() - CenterX
MoveMouse CenterX,CenterY
End Function



Function UpdateNPCs()
For Loop = 1 To Number_of_enemies
If NPCDead(Loop) = 0
NPCTime(Loop) = NPCTime(Loop) - 1
If NPCTime(Loop) < 1
NPCTime(Loop) = Rand(1,100)
NPCDirection(Loop) = Rnd(-1,1)
EndIf
If NPCPrey(Loop) = 0 TurnEntity NPC(Loop),0,NPCDirection(Loop),0

If Truce > 0
Truce = Truce - 1
If Truce = 0 Writing = "Let the killing begin!"
FlushMouse
Else
ChooseTarget()
Attack()
DeadTarget()
EndIf
If NPCPrey(Loop) = 0
MoveEntity NPC(Loop),0,0,1
ElseIf NPCDead(NPCPrey(Loop)) = 0
If EntityDistance(NPC(Loop),NPC(NPCPrey(Loop))) > 250 MoveEntity NPC(Loop),0,0,1
EndIf
EndIf
Next
End Function





;Function









Function Gunshot()


If MouseHit(1) NPCFiredShot(Number_of_enemies + 1) = 1








For Loop = 1 To Number_of_enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop) > 0
If NPCDead(NPCPrey(Loop)) = 0
NPCFiringDelay(Loop) = NPCFiringDelay(Loop) - 1
If NPCFiringDelay(Loop) <= 0
If EntityDistance(NPC(Loop),NPC(NPCPrey(Loop))) < 285
NPCFiredShot(Loop) = 1
NPCFiringDelay(Loop) = Rnd(30,40)
EndIf
EndIf
EndIf
EndIf
EndIf
Next





For Loop = 1 To Number_of_enemies + 1
If NPCDead(Loop) = 0
If NPCFiredShot(Loop) = 1
TurnEntity NPC(Loop),0,Rnd(-NPCInaccuracy(Loop),NPCInaccuracy(Loop)),0
ShowEntity NPCGunshot(Loop)

DeleteEntity% = EntityPick(NPCInjurePoint(Loop),300)
NPCFiredShot(Loop) = 2
ElseIf NPCFiredShot(Loop) = 2
NPCFiredShot(Loop) = 0
HideEntity NPCGunshot(Loop)
EndIf
EndIf

For Loop2 = 1 To Number_of_Enemies + 1

If NPC(Loop2) = DeleteEntity%
If NPCDead(Loop2) = 0
If Loop2 = Number_of_Enemies + 1 GameOver(NPCName(Loop))
PositionEntity NPCBlood(Loop2),EntityX(NPC(Loop2)),-10,EntityZ(NPC(Loop2))
FreeEntity NPC(Loop2)
;NPC(Loop2) = 0
NPCDead(Loop2) = 1
ShowEntity NPCBlood(Loop2)
If Loop = Number_of_Enemies + 1 Kill(NPCName(Loop2))
EndIf
EndIf
Next
Next


;Is An NPC Dead

End Function













Function Rename$()

Return Namegen$() + " " + Namegen$()

End Function
Function Namegen$()
NameLength = Rand(4,8)
Local Letter$[12]
For loop = 1 To namelength
char = Rand(1,26)

Select char
Case 1
Letter[Loop] = "a"
Vowel = Vowel + 1
Case 2
Letter[Loop] = "b"
Case 3
Letter[Loop] = "c"
Case 4
Letter[Loop] = "d"
Case 5
Letter[Loop] = "e"
Vowel = Vowel + 1
Case 6
Letter[Loop] = "f"
Case 7
Letter[Loop] = "g"
Case 8
Letter[Loop] = "h"
Case 9
Letter[Loop] = "i"
Vowel = Vowel + 1
Case 10
Letter[Loop] = "j"
Case 11
Letter[Loop] = "k"
Case 12
Letter[Loop] = "l"
Case 13
Letter[Loop] = "m"
Case 14
Letter[Loop] = "n"
Case 15
Letter[Loop] = "o"
Vowel = Vowel + 1
Case 16
Letter[Loop] = "p"
Case 17
Letter[Loop] = "q"
Case 18
Letter[Loop] = "r"
Case 19
Letter[Loop] = "s"
Case 20
Letter[Loop] = "t"
Case 21
Letter[Loop] = "u"
Vowel = Vowel + 1
Case 22
Letter[Loop] = "v"
Case 23
Letter[Loop] = "w"
Case 24
Letter[Loop] = "x"
Case 25
Letter[Loop] = "y"
Vowel = Vowel + 1
Case 26
Letter[Loop] = "z"
End Select



If Vowel < Ceil(loop/2) Letter[Loop] = Re_vowel$() Vowel = Vowel + 1
If Loop = 1 Letter[Loop] = Upper$(Letter[Loop])
Name$ = name + Letter[Loop]
Next

Return Name
End Function


Function Re_vowel$()
Numb = Rand(1,64)
If Numb > 0 And Numb <= 16 Return "a"
If Numb > 16 And Numb <= 34 Return "e"
If Numb > 34 And Numb <= 46 Return "i"
If Numb > 46 And Numb <= 56 Return "o"
If Numb > 56 And Numb <= 62 Return "u"
If Numb > 62 Return "y"
End Function


Function FPS()

FramesPerSecond# = MilliSecs() - FrameCount
FrameCount = MilliSecs()

Return 1000 / FramesPerSecond
End Function




Function DeadTarget()
For Loop = 1 To Number_of_Enemies
If NPCDead(Loop) = 0
If NPCDead(NPCPrey(Loop)) = 1 NPCPrey(Loop) = 0 
EndIf
Next
End Function



Function ChooseTarget()

For Loop = 1 To Number_Of_Enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop) = 0
For Loop2 = 1 To Number_Of_Enemies + 1
If NPCDead(Loop2) = 0
If Not Loop = Loop2
If JRAILib_Engage(NPC(Loop),80,NPC(Loop2),500) NPCPrey(Loop) = Loop2
EndIf
EndIf
Next
EndIf
EndIf
Next

End Function


Function Attack()
For Loop = 1 To Number_Of_Enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop)> 0 TurnEntity NPC(Loop),0,JRAILib_Orient#(NPC(Loop),NPC(NPCPrey(Loop)),5,1,9),0
EndIf
Next
End Function 



Function JRAILib_Orient#(JRAILib_Source,JRAILib_Recipient,JRAILib_Speed#,JRAILib_ReducedSpeed#,JRAILib_ReducedDistance#)
JRAILib_DeltaPitch# = DeltaYaw#(JRAILib_Source,JRAILib_Recipient)


If Abs(JRAILib_DeltaPitch) <= JRAILib_ReducedSpeed Return JRAILib_Pitch# + JRAILib_DeltaPitch

If Abs(JRAILib_DeltaPitch) > JRAILib_ReducedDistance
JRAILib_PitchChangeAmount# = JRAILib_Speed
Else
JRAILib_PitchChangeAmount# = JRAILib_ReducedSpeed
EndIf
If JRAILib_DeltaPitch# < 0 JRAILib_PitchChangeAmount# = JRAILib_PitchChangeAmount# * -1



Return JRAILib_PitchChangeAmount#
 
End Function
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Function JRAILib_Engage(JRAILib_Hunter,JRAILib_BowlOfVision,JRAILib_Prey,JRAILib_SightRange)
JRAILib_DeltaPitch = DeltaYaw#(JRAILib_Hunter,JRAILib_Prey)
If Abs(JRAILib_DeltaPitch) <= JRAILib_BowlOfVision And EntityDistance(JRAILib_Hunter,JRAILib_Prey) <= JRAILib_SightRange And EntityVisible(JRAILib_Hunter,JRAILib_Prey)
Return 1
Else
Return 0
EndIf
End Function

Function GameOver(Murderer$)
ClsColor 128,0,0
Cls
Text CenterX,0,"You were gunned down by " + Murderer,1,0
Flip
Repeat
Until KeyHit(1)
End
End Function
Function Kill(Victim$)
Writing = "You Killed " + Victim
End Function

I just changed the people. Any Comments?

Nice!

I think its pretty fun to play.

It looks like some of the old time arcade games, It just has a very
retro feel to it.

I'm not sure if that was what you were going for or not, but great job.

The Mighty WERDNA(Lord Of Darkness)

If you want it to feel more retro, you can replace
Graphics3D 800,600,0,1

with
Graphics3D 320,240,0,1


AppTitle "3d Shooter"
Graphics3D 640,480,0,1
SeedRnd MilliSecs()
Const Number_of_enemies = 10
Global CenterX = GraphicsWidth()/2
Global CenterY = GraphicsHeight()/2
Global Abort = 0
Global FrameCount = MilliSecs()
Global Camera = CreateCamera()
CameraRange Camera,1,10000
Global Truce = 500 * Number_of_enemies
Global DoFPS
Global Writing$ = "Press Enter to view FPS"
;assemble the player
Global CloneMe = CreatePivot()
Global Player = CreateCylinder()
EntityParent Player,CloneMe
EntityColor Player,0,0,255
Global XLook
Eyes = CreateImage(16,16)
SetBuffer ImageBuffer(Eyes)
Color 200,155,45
Rect 0,0,16,16
Color 64,32,0
Plot 4,8
Plot 12,8
Global FPSCalc = 0
TranslateEntity CloneMe,0,-7,1
TranslateEntity Camera,0,-3,1
ScaleMesh Player,1,3,1
Gun = CreateCylinder()
EntityParent Gun,CloneMe
PositionEntity Gun,0,2,2
ScaleMesh Gun,0.25,2,0.25
RotateEntity Gun,90,0,0
EntityColor gun,64,32,0
Sight = CreateCube()
ScaleMesh Sight,0.0125,0.1,0.1
EntityColor Sight,0,0,0
HeadTexture = CreateTexture(64,64)
SetBuffer TextureBuffer(HeadTexture)
Color 200,155,45
Rect 0,0,64,64
DrawImage Eyes,8,16
Global Grass = CreateTexture(32,32)
Global Light = CreateLight(2)
LightColor Light,10,10,10
EntityParent Light,Camera
Global Head = CreateSphere()
Global Turban = CreateSphere()
RotateEntity Head,0,-90,0
EntityParent Head,CloneMe
EntityParent Turban,CloneMe
EntityColor Turban,230,230,230
ScaleMesh Turban,1.25,0.75,1.25
EntityParent Sight,CloneMe
PositionEntity Sight,0,2.25,3.75
EntityTexture Head,HeadTexture
PositionEntity Head,0,4,0
PositionEntity Turban,0,5,0
SetBuffer TextureBuffer(Grass);Make grass texture

Color 0,255,0
Rect 0,0,16,16
Rect 16,16,16,16
Color 0,250,0
Rect 16,0,16,16
Rect 0,16,16,16
SetBuffer BackBuffer()
EntityType CloneMe,17
EntityRadius CloneMe,3
EntityPickMode CloneMe,1
;done...
;make bullet
Bullet = CreateCylinder()
RotateEntity Bullet,90,0,0
ScaleMesh Bullet,0.125,150,0.125
EntityColor Bullet,255,255,16
Target = CreatePivot()
;RotateEntity Target,90,0,0
Blood = CreateCylinder()
ScaleMesh Blood,5,.001,5
EntityColor Blood,160,0,0
Color 255,128,0
;done...
;Build Enemies
Dim NPC(Number_of_enemies + 1)
Dim NPCBlood(Number_of_enemies)
Dim NPCName$(Number_of_enemies)
Dim NPCPrey(Number_of_enemies + 1)
Dim NPCDead(Number_of_enemies + 1)
Dim NPCInjurePoint(Number_of_enemies + 1)
Dim NPCFiredShot(Number_of_enemies + 1)
Dim NPCDirection(Number_of_enemies)
Dim NPCTime(Number_of_enemies)
Dim NPCGunshot(Number_of_enemies + 1)
Dim NPCInaccuracy#(Number_of_enemies + 1)
Dim NPCFiringDelay(Number_of_enemies + 1)
For loop = 1 To Number_of_enemies
NPCName(Loop) = Rename$()
NPC(Loop) = CopyEntity(CloneMe)
NPCGunshot(Loop) = CopyEntity(Bullet)
NPCInjurePoint(Loop) = CopyEntity(Target)
NPCInaccuracy(Loop) = Rnd(5,15)
NPCBlood(Loop) = CopyEntity(Blood)
HideEntity NPCBlood(Loop)
EntityParent NPCInjurePoint(Loop),NPC(Loop)
PositionEntity NPCInjurePoint(Loop),0,2,1
HideEntity NPCGunshot(Loop)
EntityParent NPCGunshot(Loop),NPC(Loop)
PositionEntity NPCGunshot(Loop),0,2,150
NPCDirection(Loop) = Rnd(-1,1)
NPCTime(Loop) = Rand(1,100)
PositionEntity NPC(Loop),Rand(-100,100),-7,Rand(-100,100)
Next


NPC(Number_of_enemies + 1) = CopyEntity(CloneMe)
NPCGunshot(Loop) = CopyEntity(Bullet)
EntityParent NPCGunshot(Number_of_enemies + 1),NPC(Number_of_enemies + 1)
PositionEntity NPCGunshot(Number_of_enemies + 1),0,2,150
NPCInaccuracy(Number_of_enemies + 1) = Rnd(5,15)
HideEntity NPCGunshot(Number_of_enemies + 1)
NPCInjurePoint(Number_of_enemies + 1) = CopyEntity(Target)
EntityParent NPCInjurePoint(Number_of_enemies + 1),NPC(Number_of_enemies + 1)
PositionEntity NPCInjurePoint(Number_of_enemies + 1),0,2,1




HideEntity Blood
HideEntity CloneMe
HideEntity Bullet
HideEntity Target
HideEntity Turban

EntityParent Camera,NPC(Number_of_enemies + 1)
PositionEntity NPC(Number_of_enemies + 1),Rand(-100,100),-7,Rand(-100,100)


Collisions 17,17,1,2







Global Ground = CreatePlane()
EntityTexture Ground,Grass
TranslateEntity Ground,0,-10,0


Runtime()
End




Function Runtime();Runtime function

Repeat
Timer = MilliSecs()


Bounderies()
UpdateNPCs()
MouseLook()
CheckDead()
If Truce = 0 GunShot()
TurnEntity NPC(Number_of_enemies + 1),0,-Xlook/5,0
MoveEntity NPC(Number_of_enemies + 1),KeyDown(205) - KeyDown(203),0,KeyDown(200) * 2 - KeyDown(208)
UpdateWorld()
RenderWorld()
If KeyDown(28) Text CenterX,10,"FPS:",1,0
If KeyDown(28) Text CenterX,20,FPS(),1,0
Text CenterX,0,Writing,1,0
Flip


If KeyHit(1) Abort = 1


While Not MilliSecs() - Timer > 25
Wend
Until Abort = 1

End Function

Function MouseLook()

Xlook = MouseX() - CenterX
MoveMouse CenterX,CenterY
End Function



Function UpdateNPCs()
For Loop = 1 To Number_of_enemies
If NPCDead(Loop) = 0
NPCTime(Loop) = NPCTime(Loop) - 1
If NPCTime(Loop) < 1
NPCTime(Loop) = Rand(1,100)
NPCDirection(Loop) = Rnd(-1,1)
EndIf
If NPCPrey(Loop) = 0 TurnEntity NPC(Loop),0,NPCDirection(Loop),0

If Truce > 0
Truce = Truce - 1
If Truce = 0 Writing = "Let the killing begin!"
FlushMouse
Else
ChooseTarget()
Attack()
DeadTarget()
EndIf
If NPCPrey(Loop) = 0
MoveEntity NPC(Loop),0,0,1
ElseIf NPCDead(NPCPrey(Loop)) = 0
If EntityDistance(NPC(Loop),NPC(NPCPrey(Loop))) > 250 MoveEntity NPC(Loop),0,0,1
EndIf
EndIf
Next
End Function





;Function









Function Gunshot()


If MouseHit(1) NPCFiredShot(Number_of_enemies + 1) = 1








For Loop = 1 To Number_of_enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop) > 0
If NPCDead(NPCPrey(Loop)) = 0
NPCFiringDelay(Loop) = NPCFiringDelay(Loop) - 1
If NPCFiringDelay(Loop) <= 0
If EntityDistance(NPC(Loop),NPC(NPCPrey(Loop))) < 285
NPCFiredShot(Loop) = 1
NPCFiringDelay(Loop) = Rnd(30,40)
EndIf
EndIf
EndIf
EndIf
EndIf
Next





For Loop = 1 To Number_of_enemies + 1
If NPCDead(Loop) = 0
If NPCFiredShot(Loop) = 1
TurnEntity NPC(Loop),0,Rnd(-NPCInaccuracy(Loop),NPCInaccuracy(Loop)),0
ShowEntity NPCGunshot(Loop)

DeleteEntity% = EntityPick(NPCInjurePoint(Loop),300)
NPCFiredShot(Loop) = 2
ElseIf NPCFiredShot(Loop) = 2
NPCFiredShot(Loop) = 0
HideEntity NPCGunshot(Loop)
EndIf
EndIf

For Loop2 = 1 To Number_of_Enemies + 1

If NPC(Loop2) = DeleteEntity%
If NPCDead(Loop2) = 0
If Loop2 = Number_of_Enemies + 1 GameOver(NPCName(Loop))
PositionEntity NPCBlood(Loop2),EntityX(NPC(Loop2)),-10,EntityZ(NPC(Loop2))
FreeEntity NPC(Loop2)
;NPC(Loop2) = 0
NPCDead(Loop2) = 1
ShowEntity NPCBlood(Loop2)
If Loop = Number_of_Enemies + 1 Kill(NPCName(Loop2))
EndIf
EndIf
Next
Next


;Is An NPC Dead

End Function













Function Rename$()

Return Namegen$() + " " + Namegen$()

End Function
Function Namegen$()
NameLength = Rand(4,8)
Local Letter$[12]
For loop = 1 To namelength
char = Rand(1,26)

Select char
Case 1
Letter[Loop] = "a"
Vowel = Vowel + 1
Case 2
Letter[Loop] = "b"
Case 3
Letter[Loop] = "c"
Case 4
Letter[Loop] = "d"
Case 5
Letter[Loop] = "e"
Vowel = Vowel + 1
Case 6
Letter[Loop] = "f"
Case 7
Letter[Loop] = "g"
Case 8
Letter[Loop] = "h"
Case 9
Letter[Loop] = "i"
Vowel = Vowel + 1
Case 10
Letter[Loop] = "j"
Case 11
Letter[Loop] = "k"
Case 12
Letter[Loop] = "l"
Case 13
Letter[Loop] = "m"
Case 14
Letter[Loop] = "n"
Case 15
Letter[Loop] = "o"
Vowel = Vowel + 1
Case 16
Letter[Loop] = "p"
Case 17
Letter[Loop] = "q"
Case 18
Letter[Loop] = "r"
Case 19
Letter[Loop] = "s"
Case 20
Letter[Loop] = "t"
Case 21
Letter[Loop] = "u"
Vowel = Vowel + 1
Case 22
Letter[Loop] = "v"
Case 23
Letter[Loop] = "w"
Case 24
Letter[Loop] = "x"
Case 25
Letter[Loop] = "y"
Vowel = Vowel + 1
Case 26
Letter[Loop] = "z"
End Select



If Vowel < Ceil(loop/2) Letter[Loop] = Re_vowel$() Vowel = Vowel + 1
If Loop = 1 Letter[Loop] = Upper$(Letter[Loop])
Name$ = name + Letter[Loop]
Next

Return Name
End Function


Function Re_vowel$()
Numb = Rand(1,64)
If Numb > 0 And Numb <= 16 Return "a"
If Numb > 16 And Numb <= 34 Return "e"
If Numb > 34 And Numb <= 46 Return "i"
If Numb > 46 And Numb <= 56 Return "o"
If Numb > 56 And Numb <= 62 Return "u"
If Numb > 62 Return "y"
End Function


Function FPS()

FramesPerSecond# = MilliSecs() - FrameCount
FrameCount = MilliSecs()

Return 1000 / FramesPerSecond
End Function




Function DeadTarget()
For Loop = 1 To Number_of_Enemies
If NPCDead(Loop) = 0
If NPCDead(NPCPrey(Loop)) = 1 NPCPrey(Loop) = 0 
EndIf
Next
End Function



Function ChooseTarget()

For Loop = 1 To Number_Of_Enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop) = 0
For Loop2 = 1 To Number_Of_Enemies + 1
If NPCDead(Loop2) = 0
If Not Loop = Loop2
If JRAILib_Engage(NPC(Loop),80,NPC(Loop2),500) NPCPrey(Loop) = Loop2
EndIf
EndIf
Next
EndIf
EndIf
Next

End Function


Function Attack()
For Loop = 1 To Number_Of_Enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop)> 0 TurnEntity NPC(Loop),0,JRAILib_Orient#(NPC(Loop),NPC(NPCPrey(Loop)),5,1,9),0
EndIf
Next
End Function 



Function JRAILib_Orient#(JRAILib_Source,JRAILib_Recipient,JRAILib_Speed#,JRAILib_ReducedSpeed#,JRAILib_ReducedDistance#)
JRAILib_DeltaPitch# = DeltaYaw#(JRAILib_Source,JRAILib_Recipient)


If Abs(JRAILib_DeltaPitch) <= JRAILib_ReducedSpeed Return JRAILib_Pitch# + JRAILib_DeltaPitch

If Abs(JRAILib_DeltaPitch) > JRAILib_ReducedDistance
JRAILib_PitchChangeAmount# = JRAILib_Speed
Else
JRAILib_PitchChangeAmount# = JRAILib_ReducedSpeed
EndIf
If JRAILib_DeltaPitch# < 0 JRAILib_PitchChangeAmount# = JRAILib_PitchChangeAmount# * -1



Return JRAILib_PitchChangeAmount#
 
End Function
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Function JRAILib_Engage(JRAILib_Hunter,JRAILib_BowlOfVision,JRAILib_Prey,JRAILib_SightRange)
JRAILib_DeltaPitch = DeltaYaw#(JRAILib_Hunter,JRAILib_Prey)
If Abs(JRAILib_DeltaPitch) <= JRAILib_BowlOfVision And EntityDistance(JRAILib_Hunter,JRAILib_Prey) <= JRAILib_SightRange And EntityVisible(JRAILib_Hunter,JRAILib_Prey)
Return 1
Else
Return 0
EndIf
End Function

Function GameOver(Murderer$)
ClsColor 128,0,0
Cls
Text CenterX,0,"You were gunned down by " + Murderer,1,0
Flip
Repeat
Until KeyHit(1)
End
End Function
Function Kill(Victim$)
Writing = "You Killed " + Victim
End Function
Function Bounderies()
For Loop = 1 To Number_of_enemies + 1
If NPCDead(Loop) = 0
If EntityX(NPC(Loop)) > 1000 Or EntityX(NPC(Loop)) < -1000 Or EntityZ(NPC(Loop)) > 1000 Or EntityZ(NPC(Loop)) < -1000
PositionEntity NPC(Loop),Rand(-1000,1000),-7,Rand(-1000,1000)
EndIf
EndIf
Next
End Function
Function Victory()
Color 192,192,255
ClsColor 0,0,255
Cls
Text CenterX,0,"You are victorius",1,0
Flip
Repeat
Until JoyHit(8) Or KeyHit(1)
End
End Function
Function CheckDead()
For Loop = 1 To Number_of_enemies 
If NPCDead(Loop) = 0 continuegame = 1
Next
If continuegame <> 1 Victory()
End Function

Set Bounderies

Its working now, weird. maybe it glitched?

I can't shoot for the first 5-6 secs.

That is a delay so that all the enemies can get away. If it is removed, the enemies would kill you on the first frame.

Um.. Everytime I shoot, it jolts to the left or right.

Is this meant to simulate recoil reducing shot accuracy? Or am I just seeing glitches?

One suggestion: Perhaps you could place some static objects or give the ground some kind of texture (just a grid on the floor plane would do) so that you get a sense of movement even when you can't see the opponents.

Last man standing is my favourite kind of competition. Never practical in multiplayer though because all the dead players are left twiddling their thumbs whilst the remaining players fight it out.

I like what you've got here given the short time it took to put together, tho. :)

In one day you've made a solid small game, in a week you could do wolfenstein, 1 month of the same efforts and you could make a nice doom clone.... etc etc.

Yes that is recoil. Without it the enemies could easily kill you. I did basically all of it in one day. I did the name generation function previously. And there is a grid on the ground (You need to look very closely), but I will think about your suggestion of stacic objects.







This is the same thing, but using a game controller instead.
AppTitle "3d Shooter"
Graphics3D 640,480,0,1
SeedRnd MilliSecs()
Const Number_of_enemies = 10
Global CenterX = GraphicsWidth()/2
Global CenterY = GraphicsHeight()/2
Global Abort = 0
Global FrameCount = MilliSecs()
Global Camera = CreateCamera()
CameraRange Camera,1,10000
Global Truce = 500 * Number_of_enemies
Global DoFPS
Global Writing$ = "Press Enter to view FPS"
Global SemiAuto = 0
;assemble the player
Global CloneMe = CreatePivot()
Global Player = CreateCylinder()
EntityParent Player,CloneMe
EntityColor Player,0,0,255
Global XLook
Eyes = CreateImage(16,16)
SetBuffer ImageBuffer(Eyes)
Color 200,155,45
Rect 0,0,16,16
Color 64,32,0
Plot 4,8
Plot 12,8

Global FPSCalc = 0
TranslateEntity CloneMe,0,-7,1
TranslateEntity Camera,0,-3,1
ScaleMesh Player,1,3,1
Gun = CreateCylinder()
EntityParent Gun,CloneMe
PositionEntity Gun,0,2,2
ScaleMesh Gun,0.25,2,0.25
RotateEntity Gun,90,0,0
EntityColor gun,64,32,0
Sight = CreateCube()
ScaleMesh Sight,0.0125,0.1,0.1
EntityColor Sight,0,0,0
HeadTexture = CreateTexture(64,64)
SetBuffer TextureBuffer(HeadTexture)
Color 200,155,45
Rect 0,0,64,64
DrawImage Eyes,8,16
Global Grass = CreateTexture(32,32)
Global Light = CreateLight(2)
LightColor Light,10,10,10
EntityParent Light,Camera
Global Head = CreateSphere()
Global Turban = CreateSphere()
RotateEntity Head,0,-90,0
EntityParent Head,CloneMe
EntityParent Turban,CloneMe
EntityColor Turban,230,230,230
ScaleMesh Turban,1.25,0.75,1.25
EntityParent Sight,CloneMe
PositionEntity Sight,0,2.25,3.75
EntityTexture Head,HeadTexture
PositionEntity Head,0,4,0
PositionEntity Turban,0,5,0





SetBuffer TextureBuffer(Grass);Make grass texture

Color 0,255,0
Rect 0,0,16,16
Rect 16,16,16,16
Color 0,250,0
Rect 16,0,16,16
Rect 0,16,16,16
SetBuffer BackBuffer()
EntityType CloneMe,17
EntityRadius CloneMe,3
EntityPickMode CloneMe,1
;done...
;make bullet
Bullet = CreateCylinder()
RotateEntity Bullet,90,0,0
ScaleMesh Bullet,0.125,150,0.125
EntityColor Bullet,255,255,16
Target = CreatePivot()
;RotateEntity Target,90,0,0
Blood = CreateCylinder()
ScaleMesh Blood,5,.001,5
EntityColor Blood,160,0,0
Color 255,128,0
;done...
;Build Enemies
Dim NPC(Number_of_enemies + 1)
Dim NPCBlood(Number_of_enemies)
Dim NPCName$(Number_of_enemies)
Dim NPCPrey(Number_of_enemies + 1)
Dim NPCDead(Number_of_enemies + 1)
Dim NPCInjurePoint(Number_of_enemies + 1)
Dim NPCFiredShot(Number_of_enemies + 1)
Dim NPCDirection(Number_of_enemies)
Dim NPCTime(Number_of_enemies)
Dim NPCGunshot(Number_of_enemies + 1)
Dim NPCInaccuracy#(Number_of_enemies + 1)
Dim NPCFiringDelay(Number_of_enemies + 1)
For loop = 1 To Number_of_enemies
NPCName(Loop) = Rename$()
NPC(Loop) = CopyEntity(CloneMe)
NPCGunshot(Loop) = CopyEntity(Bullet)
NPCInjurePoint(Loop) = CopyEntity(Target)
NPCInaccuracy(Loop) = Rnd(5,15)
NPCBlood(Loop) = CopyEntity(Blood)
HideEntity NPCBlood(Loop)
EntityParent NPCInjurePoint(Loop),NPC(Loop)
PositionEntity NPCInjurePoint(Loop),0,2,1
HideEntity NPCGunshot(Loop)
EntityParent NPCGunshot(Loop),NPC(Loop)
PositionEntity NPCGunshot(Loop),0,2,150
NPCDirection(Loop) = Rnd(-1,1)
NPCTime(Loop) = Rand(1,100)
PositionEntity NPC(Loop),Rand(-100,100),-7,Rand(-100,100)
Next


NPC(Number_of_enemies + 1) = CopyEntity(CloneMe)
NPCGunshot(Loop) = CopyEntity(Bullet)
EntityParent NPCGunshot(Number_of_enemies + 1),NPC(Number_of_enemies + 1)
PositionEntity NPCGunshot(Number_of_enemies + 1),0,2,150
NPCInaccuracy(Number_of_enemies + 1) = Rnd(5,15)
HideEntity NPCGunshot(Number_of_enemies + 1)
NPCInjurePoint(Number_of_enemies + 1) = CopyEntity(Target)
EntityParent NPCInjurePoint(Number_of_enemies + 1),NPC(Number_of_enemies + 1)
PositionEntity NPCInjurePoint(Number_of_enemies + 1),0,2,1




HideEntity Blood
HideEntity CloneMe
HideEntity Bullet
HideEntity Target
HideEntity Turban

EntityParent Camera,NPC(Number_of_enemies + 1)
PositionEntity NPC(Number_of_enemies + 1),Rand(-100,100),-7,Rand(-100,100)


Collisions 17,17,1,2







Global Ground = CreatePlane()
EntityTexture Ground,Grass
TranslateEntity Ground,0,-10,0


Runtime()
End




Function Runtime();Runtime function

Repeat
Timer = MilliSecs()


Bounderies()
UpdateNPCs()
MouseLook()
CheckDead()
If Truce = 0 GunShot()
TurnEntity NPC(Number_of_enemies + 1),0,-Int(JoyPitch())/100,0
ForwardSpeed% = -Int(JoyY())
If ForwardSpeed > 0 ForwardSpeed = ForwardSpeed * 2
MoveEntity NPC(Number_of_enemies + 1),Int(JoyX()),0,ForwardSpeed
UpdateWorld()
RenderWorld()
If JoyDown(7) Text CenterX,10,"FPS:",1,0
If JoyDown(7) Text CenterX,20,FPS(),1,0
Text CenterX,0,Writing,1,0
Flip


If JoyHit(8) Or KeyHit(1)  Abort = 1


While Not MilliSecs() - Timer > 25
Wend
Until Abort = 1

End Function

Function MouseLook()


End Function



Function UpdateNPCs()
For Loop = 1 To Number_of_enemies
If NPCDead(Loop) = 0
NPCTime(Loop) = NPCTime(Loop) - 1
If NPCTime(Loop) < 1
NPCTime(Loop) = Rand(1,100)
NPCDirection(Loop) = Rnd(-1,1)
EndIf
If NPCPrey(Loop) = 0 TurnEntity NPC(Loop),0,NPCDirection(Loop),0

If Truce > 0
Truce = Truce - 1
If Truce = 0 Writing = "Let the killing begin!"
FlushMouse
Else
ChooseTarget()
Attack()
DeadTarget()
EndIf
If NPCPrey(Loop) = 0
MoveEntity NPC(Loop),0,0,1
ElseIf NPCDead(NPCPrey(Loop)) = 0
If EntityDistance(NPC(Loop),NPC(NPCPrey(Loop))) > 250 MoveEntity NPC(Loop),0,0,1
EndIf
EndIf
Next
End Function





;Function









Function Gunshot()


If TriggerHit() = 1 NPCFiredShot(Number_of_enemies + 1) = 1








For Loop = 1 To Number_of_enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop) > 0
If NPCDead(NPCPrey(Loop)) = 0
NPCFiringDelay(Loop) = NPCFiringDelay(Loop) - 1
If NPCFiringDelay(Loop) <= 0
If EntityDistance(NPC(Loop),NPC(NPCPrey(Loop))) < 285
NPCFiredShot(Loop) = 1
NPCFiringDelay(Loop) = Rnd(30,40)
EndIf
EndIf
EndIf
EndIf
EndIf
Next





For Loop = 1 To Number_of_enemies + 1
If NPCDead(Loop) = 0
If NPCFiredShot(Loop) = 1
TurnEntity NPC(Loop),0,Rnd(-NPCInaccuracy(Loop),NPCInaccuracy(Loop)),0
ShowEntity NPCGunshot(Loop)

DeleteEntity% = EntityPick(NPCInjurePoint(Loop),300)
NPCFiredShot(Loop) = 2
ElseIf NPCFiredShot(Loop) = 2
NPCFiredShot(Loop) = 0
HideEntity NPCGunshot(Loop)
EndIf
EndIf

For Loop2 = 1 To Number_of_Enemies + 1

If NPC(Loop2) = DeleteEntity%
If NPCDead(Loop2) = 0
If Loop2 = Number_of_Enemies + 1 GameOver(NPCName(Loop))
PositionEntity NPCBlood(Loop2),EntityX(NPC(Loop2)),-10,EntityZ(NPC(Loop2))
FreeEntity NPC(Loop2)
;NPC(Loop2) = 0
NPCDead(Loop2) = 1
ShowEntity NPCBlood(Loop2)
If Loop = Number_of_Enemies + 1 Kill(NPCName(Loop2))
EndIf
EndIf
Next
Next


;Is An NPC Dead

End Function













Function Rename$()

Return Namegen$() + " " + Namegen$()

End Function
Function Namegen$()
NameLength = Rand(4,8)
Local Letter$[12]
For loop = 1 To namelength
char = Rand(1,26)

Select char
Case 1
Letter[Loop] = "a"
Vowel = Vowel + 1
Case 2
Letter[Loop] = "b"
Case 3
Letter[Loop] = "c"
Case 4
Letter[Loop] = "d"
Case 5
Letter[Loop] = "e"
Vowel = Vowel + 1
Case 6
Letter[Loop] = "f"
Case 7
Letter[Loop] = "g"
Case 8
Letter[Loop] = "h"
Case 9
Letter[Loop] = "i"
Vowel = Vowel + 1
Case 10
Letter[Loop] = "j"
Case 11
Letter[Loop] = "k"
Case 12
Letter[Loop] = "l"
Case 13
Letter[Loop] = "m"
Case 14
Letter[Loop] = "n"
Case 15
Letter[Loop] = "o"
Vowel = Vowel + 1
Case 16
Letter[Loop] = "p"
Case 17
Letter[Loop] = "q"
Case 18
Letter[Loop] = "r"
Case 19
Letter[Loop] = "s"
Case 20
Letter[Loop] = "t"
Case 21
Letter[Loop] = "u"
Vowel = Vowel + 1
Case 22
Letter[Loop] = "v"
Case 23
Letter[Loop] = "w"
Case 24
Letter[Loop] = "x"
Case 25
Letter[Loop] = "y"
Vowel = Vowel + 1
Case 26
Letter[Loop] = "z"
End Select



If Vowel < Ceil(loop/2) Letter[Loop] = Re_vowel$() Vowel = Vowel + 1
If Loop = 1 Letter[Loop] = Upper$(Letter[Loop])
Name$ = name + Letter[Loop]
Next

Return Name
End Function


Function Re_vowel$()
Numb = Rand(1,64)
If Numb > 0 And Numb <= 16 Return "a"
If Numb > 16 And Numb <= 34 Return "e"
If Numb > 34 And Numb <= 46 Return "i"
If Numb > 46 And Numb <= 56 Return "o"
If Numb > 56 And Numb <= 62 Return "u"
If Numb > 62 Return "y"
End Function


Function FPS()

FramesPerSecond# = MilliSecs() - FrameCount
FrameCount = MilliSecs()

Return 1000 / FramesPerSecond
End Function




Function DeadTarget()
For Loop = 1 To Number_of_Enemies
If NPCDead(Loop) = 0
If NPCDead(NPCPrey(Loop)) = 1 NPCPrey(Loop) = 0 
EndIf
Next
End Function



Function ChooseTarget()

For Loop = 1 To Number_Of_Enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop) = 0
For Loop2 = 1 To Number_Of_Enemies + 1
If NPCDead(Loop2) = 0
If Not Loop = Loop2
If JRAILib_Engage(NPC(Loop),80,NPC(Loop2),500) NPCPrey(Loop) = Loop2
EndIf
EndIf
Next
EndIf
EndIf
Next

End Function


Function Attack()
For Loop = 1 To Number_Of_Enemies
If NPCDead(Loop) = 0
If NPCPrey(Loop)> 0 TurnEntity NPC(Loop),0,JRAILib_Orient#(NPC(Loop),NPC(NPCPrey(Loop)),5,1,9),0
EndIf
Next
End Function 



Function JRAILib_Orient#(JRAILib_Source,JRAILib_Recipient,JRAILib_Speed#,JRAILib_ReducedSpeed#,JRAILib_ReducedDistance#)
JRAILib_DeltaPitch# = DeltaYaw#(JRAILib_Source,JRAILib_Recipient)


If Abs(JRAILib_DeltaPitch) <= JRAILib_ReducedSpeed Return JRAILib_Pitch# + JRAILib_DeltaPitch

If Abs(JRAILib_DeltaPitch) > JRAILib_ReducedDistance
JRAILib_PitchChangeAmount# = JRAILib_Speed
Else
JRAILib_PitchChangeAmount# = JRAILib_ReducedSpeed
EndIf
If JRAILib_DeltaPitch# < 0 JRAILib_PitchChangeAmount# = JRAILib_PitchChangeAmount# * -1



Return JRAILib_PitchChangeAmount#
 
End Function
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Function JRAILib_Engage(JRAILib_Hunter,JRAILib_BowlOfVision,JRAILib_Prey,JRAILib_SightRange)
JRAILib_DeltaPitch = DeltaYaw#(JRAILib_Hunter,JRAILib_Prey)
If Abs(JRAILib_DeltaPitch) <= JRAILib_BowlOfVision And EntityDistance(JRAILib_Hunter,JRAILib_Prey) <= JRAILib_SightRange And EntityVisible(JRAILib_Hunter,JRAILib_Prey)
Return 1
Else
Return 0
EndIf
End Function

Function GameOver(Murderer$)
ClsColor 128,0,0
Cls
Text CenterX,0,"You were gunned down by " + Murderer,1,0
Flip
Repeat
Until JoyHit(8) Or KeyHit(1)
End
End Function
Function Kill(Victim$)
Writing = "You Killed " + Victim
End Function
Function Bounderies()
For Loop = 1 To Number_of_enemies + 1
If NPCDead(Loop) = 0
If EntityX(NPC(Loop)) > 1000 Or EntityX(NPC(Loop)) < -1000 Or EntityZ(NPC(Loop)) > 1000 Or EntityZ(NPC(Loop)) < -1000
PositionEntity NPC(Loop),Rand(-1000,1000),-7,Rand(-1000,1000)
EndIf
EndIf
Next
End Function



Function Victory()
Color 192,192,255
ClsColor 0,0,255
Cls
Text CenterX,0,"You are victorius",1,0
Flip
Repeat
Until JoyHit(8) Or KeyHit(1)
End
End Function
Function CheckDead()
For Loop = 1 To Number_of_enemies 
If NPCDead(Loop) = 0 continuegame = 1
Next
If continuegame <> 1 Victory()
End Function


Function TriggerHit()
If JoyZDir() < 0
SemiAuto = SemiAuto + 1
If SemiAuto = 1 Return 1
Else
SemiAuto = 0
Return 0
EndIf
End Function


Any comments?