[gameprogrammer] Re: flight simulation camera

  • From: "®£$ǖ\"v@M$Ħ ¢© $..........." <theamericansushi@xxxxxxxxx>
  • To: gameprogrammer@xxxxxxxxxxxxx
  • Date: Fri, 28 Sep 2007 20:43:09 +0530

Hey,
This is a fps game im creating using Blitz Basic. i know im very basic but
im just strating off and im really young so i have attatched the blitz basic
file
here. The problem is that when i shoot by pressing the spacebar and the
bullet hits the the square in front of me it dosent diasappear . I think i
have a taken sufficient measure for this but it still isnt coming. If you
can find the bug i would be more than happy if you could let me know
immediatly. Here is the source code. Just fix the error tell me why mine was
wrong and telle me what you did and a little explanation. To run this put
all the fiels into one folder and if you have blitz basic compiler the
picture should come and click on it and run other wise please look at the
code given below:

Graphics3D 640,480
SetBuffer BackBuffer()

type_player=1
type_ground=2
type_sky = 3
type_gallery=4
type_bullet=5

; Create camera
camera=CreateCamera()
PositionEntity camera,-50,5,10
EntityType camera,type_player
; Creating a light

light=CreateLight()

; Creating the terrain
ground=CreateTerrain(512)
PositionEntity ground, -500,0,-500
ScaleEntity ground, 10,15,10
tex=LoadTexture( "grass1.jpg" )
EntityTexture ground, tex
EntityFX ground,1
EntityType ground, type_ground
;Creating the sky

sky = CreateSphere (60)
FlipMesh sky
ScaleEntity sky, 500,500,500
PositionEntity sky, 0,50,0
sky_tex = LoadTexture ( "sky.jpg" )
EntityTexture sky,sky_tex
EntityType sky,type_sky


cube=CreateCube()
PositionEntity cube,-50,5,19
ScaleEntity cube,2,2,2
EntityType cube,type_gallery

; This following code makes our program run


gun=CreateCylinder(12)
ScaleEntity gun,0.2,0.6,0.4
RotateEntity gun,45,0,0
PositionEntity gun, EntityX(camera),EntityY(camera)-2, EntityZ(camera)+3
EntityOrder gun, -1
EntityParent gun,camera
EntityColor gun, 100,100,100
maxbull=100

fullcart=1000
Dim bullet(1000)
For i = 0 To fullcart
bullet(i)=CreateSphere()
ScaleEntity bullet(i),0.2,0.4,0.2
ShowEntity bullet(i)
Next

While Not KeyDown( 1 )

;Camera Controls

If KeyDown(200)= True Then MoveEntity camera,0,0,1
If KeyDown (208)= True Then MoveEntity camera,0,0,-1
If KeyDown(205)= True Then rx#=rx#-3
If KeyDown (203)= True Then rx#=rx#+3
If KeyDown(30)=True Then  MoveEntity camera,0,2,0
If KeyDown(44)=True Then MoveEntity camera,0,-2,0
;Control camera turning radius

If rx# > 180 Then rx#=-180
If rx# < -180 Then rx# = 180



MoveEntity camera, 0,cy#,cz#
RotateEntity camera, 0,rx#,0
If KeyDown(19) Then
t=1
EndIf

If KeyDown(57) Then
ShowEntity bullet(t)
PositionEntity bullet(t),EntityX(gun,1),EntityY(gun,1),EntityZ(gun,1)
RotateEntity
bullet(t),EntityPitch#(gun,1)-35,EntityYaw(gun,1),EntityRoll#(gun,1)
t=t+1
EndIf
Collisions type_bullet,type_gallery,2,2
Collisions type_gallery,type_bullet,2,2
Collisions type_player,type_ground,2,2
Collisions type_ground,type_player,2,2
Collisions type_sky,type_player,2,2
Collisions type_player,type_sky,2,2

For q=1 To fullcart
MoveEntity bullet(q),0,1,3
If CountCollisions (bullet(q)) Then
crash=CollisionEntity (bullet(q),1)
score#=score#+1
HideEntity crash
EndIf
Next

Text 10,20+score#,False,True

RenderWorld
UpdateWorld
Flip
Wend
End

Thanks,
-- 
Reply,
(r)(((???£   Ŝǖ"v@ˉ˘MśĦ ¢  ???)))(c)

Attachment: sky.jpg
Description: JPEG image

;  Weapon
;_______________

Graphics3D 640,480
SetBuffer BackBuffer()

type_player=1
type_ground=2
type_sky = 3
type_gallery=4
type_bullet=5

; Create camera
camera=CreateCamera()
PositionEntity camera,-50,5,10
EntityType camera,type_player 
; Creating a light

light=CreateLight()

; Creating the terrain
ground=CreateTerrain(512)
PositionEntity ground, -500,0,-500
ScaleEntity ground, 10,15,10
tex=LoadTexture( "grass1.jpg" )
EntityTexture ground, tex
EntityFX ground,1
EntityType ground, type_ground
;Creating the sky

sky = CreateSphere (60)
FlipMesh sky
ScaleEntity sky, 500,500,500
PositionEntity sky, 0,50,0
sky_tex = LoadTexture ( "sky.jpg" )
EntityTexture sky,sky_tex
EntityType sky,type_sky


cube=CreateCube()
PositionEntity cube,-50,5,19
ScaleEntity cube,2,2,2
EntityType cube,type_gallery

; This following code makes our program run


gun=CreateCylinder(12)
ScaleEntity gun,0.2,0.6,0.4
RotateEntity gun,45,0,0
PositionEntity gun, EntityX(camera),EntityY(camera)-2, EntityZ(camera)+3
EntityOrder gun, -1
EntityParent gun,camera
EntityColor gun, 100,100,100
maxbull=100

fullcart=1000
Dim bullet(1000)
For i = 0 To fullcart
bullet(i)=CreateSphere()
ScaleEntity bullet(i),0.2,0.4,0.2
ShowEntity bullet(i)
Next

While Not KeyDown( 1 )

;Camera Controls

If KeyDown(200)= True Then MoveEntity camera,0,0,1
If KeyDown (208)= True Then MoveEntity camera,0,0,-1
If KeyDown(205)= True Then rx#=rx#-3
If KeyDown (203)= True Then rx#=rx#+3
If KeyDown(30)=True Then  MoveEntity camera,0,2,0
If KeyDown(44)=True Then MoveEntity camera,0,-2,0
;Control camera turning radius

If rx# > 180 Then rx#=-180
If rx# < -180 Then rx# = 180



MoveEntity camera, 0,cy#,cz#
RotateEntity camera, 0,rx#,0
If KeyDown(19) Then
t=1
EndIf 

If KeyDown(57) Then
ShowEntity bullet(t)
PositionEntity bullet(t),EntityX(gun,1),EntityY(gun,1),EntityZ(gun,1)
RotateEntity 
bullet(t),EntityPitch#(gun,1)-35,EntityYaw(gun,1),EntityRoll#(gun,1)
t=t+1
EndIf 
Collisions type_bullet,type_gallery,2,2
Collisions type_gallery,type_bullet,2,2
Collisions type_player,type_ground,2,2
Collisions type_ground,type_player,2,2
Collisions type_sky,type_player,2,2
Collisions type_player,type_sky,2,2

For q=1 To fullcart
MoveEntity bullet(q),0,1,3
If CountCollisions (bullet(q)) Then
crash=CollisionEntity (bullet(q),1)
score#=score#+1
HideEntity crash
EndIf 
Next

Text 10,20+score#

RenderWorld
UpdateWorld
Flip
Wend
End
;  Weapon
;_______________

Graphics3D 640,480
SetBuffer BackBuffer()

type_player=1
type_ground=2
type_sky = 3
type_gallery=4
type_bullet=5

; Create camera
camera=CreateCamera()
PositionEntity camera,-50,5,10
EntityType camera,type_player 
; Creating a light

light=CreateLight()

; Creating the terrain
ground=CreateTerrain(512)
PositionEntity ground, -500,0,-500
ScaleEntity ground, 10,15,10
tex=LoadTexture( "grass1.jpg" )
EntityTexture ground, tex
EntityFX ground,1
EntityType ground, type_ground
;Creating the sky

sky = CreateSphere (60)
FlipMesh sky
ScaleEntity sky, 500,500,500
PositionEntity sky, 0,50,0
sky_tex = LoadTexture ( "sky.jpg" )
EntityTexture sky,sky_tex
EntityType sky,type_sky


cube=CreateCube()
PositionEntity cube,-50,5,19
ScaleEntity cube,2,2,2
EntityType cube,type_gallery

; This following code makes our program run


gun=CreateCylinder(12)
ScaleEntity gun,0.2,0.6,0.4
RotateEntity gun,45,0,0
PositionEntity gun, EntityX(camera),EntityY(camera)-2, EntityZ(camera)+3
EntityOrder gun, -1
EntityParent gun,camera
EntityColor gun, 100,100,100
maxbull=100

fullcart=1000
Dim bullet(1000)
For i = 0 To fullcart
bullet(i)=CreateSphere()
ScaleEntity bullet(i),0.2,0.4,0.2
ShowEntity bullet(i)
Next

While Not KeyDown( 1 )

;Camera Controls

If KeyDown(200)= True Then MoveEntity camera,0,0,1
If KeyDown (208)= True Then MoveEntity camera,0,0,-1
If KeyDown(205)= True Then rx#=rx#-3
If KeyDown (203)= True Then rx#=rx#+3
If KeyDown(30)=True Then  MoveEntity camera,0,2,0
If KeyDown(44)=True Then MoveEntity camera,0,-2,0
;Control camera turning radius

If rx# > 180 Then rx#=-180
If rx# < -180 Then rx# = 180



MoveEntity camera, 0,cy#,cz#
RotateEntity camera, 0,rx#,0
If KeyDown(19) Then
t=1
EndIf 

If KeyDown(57) Then
ShowEntity bullet(t)
PositionEntity bullet(t),EntityX(gun,1),EntityY(gun,1),EntityZ(gun,1)
RotateEntity 
bullet(t),EntityPitch#(gun,1)-35,EntityYaw(gun,1),EntityRoll#(gun,1)
t=t+1
EndIf 
Collisions type_bullet,type_gallery,2,2
Collisions type_gallery,type_bullet,2,2
Collisions type_player,type_ground,2,2
Collisions type_ground,type_player,2,2
Collisions type_sky,type_player,2,2
Collisions type_player,type_sky,2,2

For q=1 To fullcart
MoveEntity bullet(q),0,1,3
If CountCollisions (bullet(q)) Then
crash=CollisionEntity (bullet(q),1)
score#=score#+1
HideEntity crash
EndIf 
Next

Text 10,20+score#,False,True

RenderWorld
UpdateWorld
Flip
Wend
End
;  Weapon
;_______________

Graphics3D 640,480
SetBuffer BackBuffer()

type_player=1
type_ground=2
type_sky = 3
type_gallery=4
type_bullet=5

; Create camera
camera=CreateCamera()
PositionEntity camera,-50,5,10
EntityType camera,type_player 
; Creating a light

light=CreateLight()

; Creating the terrain
ground=CreateTerrain(512)
PositionEntity ground, -500,0,-500
ScaleEntity ground, 10,15,10
tex=LoadTexture( "grass1.jpg" )
EntityTexture ground, tex
EntityFX ground,1
EntityType ground, type_ground
;Creating the sky

sky = CreateSphere (60)
FlipMesh sky
ScaleEntity sky, 500,500,500
PositionEntity sky, 0,50,0
sky_tex = LoadTexture ( "sky.jpg" )
EntityTexture sky,sky_tex
EntityType sky,type_sky


cube=CreateCube()
PositionEntity cube,-50,5,19
ScaleEntity cube,2,2,2
EntityType cube,type_gallery

; This following code makes our program run


gun=CreateCylinder(12)
ScaleEntity gun,0.2,0.6,0.4
RotateEntity gun,45,0,0
PositionEntity gun, EntityX(camera),EntityY(camera)-2, EntityZ(camera)+3
EntityOrder gun, -1
EntityParent gun,camera
EntityColor gun, 100,100,100
maxbull=100

fullcart=1000
Dim bullet(1000)
For i = 0 To fullcart
bullet(i)=CreateSphere()
ScaleEntity bullet(i),0.2,0.4,0.2
ShowEntity bullet(i)
Next

While Not KeyDown( 1 )

;Camera Controls

If KeyDown(200)= True Then MoveEntity camera,0,0,1
If KeyDown (208)= True Then MoveEntity camera,0,0,-1
If KeyDown(205)= True Then rx#=rx#-3
If KeyDown (203)= True Then rx#=rx#+3
If KeyDown(30)=True Then  MoveEntity camera,0,2,0
If KeyDown(44)=True Then MoveEntity camera,0,-2,0
;Control camera turning radius

If rx# > 180 Then rx#=-180
If rx# < -180 Then rx# = 180



MoveEntity camera, 0,cy#,cz#
RotateEntity camera, 0,rx#,0
If KeyDown(19) Then
t=1
EndIf 

If KeyDown(57) Then
ShowEntity bullet(t)
PositionEntity bullet(t),EntityX(gun,1),EntityY(gun,1),EntityZ(gun,1)
RotateEntity 
bullet(t),EntityPitch#(gun,1)-35,EntityYaw(gun,1),EntityRoll#(gun,1)
t=t+1
EndIf 
Collisions type_bullet,type_gallery,2,2
Collisions type_gallery,type_bullet,2,2
Collisions type_player,type_ground,2,2
Collisions type_ground,type_player,2,2
Collisions type_sky,type_player,2,2
Collisions type_player,type_sky,2,2

For q=1 To fullcart
MoveEntity bullet(q),0,1,3
If CountCollisions (bullet(q)) Then
crash=CollisionEntity (bullet(q),1)
score#=score#+1
HideEntity crash
EndIf 
Next

Text 10,20+score#,False,True

RenderWorld
UpdateWorld
Flip
Wend
End

Attachment: grass1.jpg
Description: JPEG image

Other related posts: