This has probably happened before.
I set up collisions for my bullets so that they would stick in the ground like arrows, but when I gave the EntityType command for the bullets I found that I could only fire in certain areas.
I have yet to clean up my code so please bear with me:
I set up collisions for my bullets so that they would stick in the ground like arrows, but when I gave the EntityType command for the bullets I found that I could only fire in certain areas.
I have yet to clean up my code so please bear with me:
Graphics3D 1024,764 SetBuffer BackBuffer() ;Types type_player=1 type_terrain=2 type_missile=3 ;Creating the camera cam=CreateCamera() ScaleEntity cam,1,1,1 PositionEntity cam,0,0,0 EntityType cam,type_player EntityRadius cam,5 ground=LoadTerrain("Canyon1.bmp") ScaleEntity ground,5,300,5 PositionEntity ground,-500,-200,-500 tex=LoadTexture("Desert Sand.jpg") ScaleTexture tex,50,50 EntityTexture ground,tex EntityType ground,type_terrain sky=CreateSphere(40) ScaleEntity sky,5000,5000,-5000 PositionEntity sky,0,-500,0 tex2=LoadTexture("sky 1.jpg") EntityTexture sky,tex2 RotateEntity sky,0,0,90 EntityFX sky,1 gun=LoadMesh("Gun.3ds") PositionEntity gun,0.2,-0.25,.5 ScaleEntity gun,.005,.005,.005 RotateEntity gun,0,90,-90 tex3=LoadTexture("Metal 3.jpg") EntityTexture gun,tex3 EntityParent gun,cam EntityType gun,type_player EntityRadius gun,.005 HidePointer light=CreateLight() ;Ceating the bullets fullmag=100 Dim bullet(fullmag) For i=0 To fullmag bullet(i)=CreateSphere() EntityColor bullet(i),255,217,0 EntityFX bullet(i),1 ScaleEntity bullet(i),.02,.02,.4 HideEntity bullet(i) EntityType bullet(i),type_missile EntityRadius bullet(i),.02,.02 Next ;Curve value Function CurveValue#(current#,destination#,curve) current#=current#+((destination#-current#)/curve) Return current# End Function ;How far the camera can see cam_range=10000 ;Collision method & respons Collisions type_player,type_terrain,2,2 Collisions type_missile,type_terrain,2,1 While Not KeyDown(1) ;How near the camera can see CameraRange cam,.1,cam_range ;Controls If KeyDown(205)=True Then MoveEntity cam,.3,0,0 If KeyDown(203)=True Then MoveEntity cam,-.3,0,0 If KeyDown(208)=True Then MoveEntity cam,0,0,-0.3 If KeyDown(200)=True Then MoveEntity cam,0,0,.3 ;Mouse movement mxs=MouseXSpeed()*.25 mys=MouseYSpeed()*.25 dest_xangle#=dest_xangle#+mys dest_yangle#=dest_yangle#-mxs xangle#=CurveValue#(xangle#,dest_xangle#,3) yangle#=CurveValue#(yangle#,dest_yangle#,3) RotateEntity cam,xangle#,yangle#,0 MoveMouse GraphicsWidth()/2,GraphicsHeight()/2 ;Firing bullets (for real) If MouseHit(1) And reload=0 Then ShowEntity bullet(t) EntityParent bullet(t),gun PositionEntity bullet(t),1,-1.5,-10 RotateEntity bullet(t),-90,0,0 EntityParent bullet(t),0 t=t+1 bam=LoadSound("pistol.wav") PlaySound bam EndIf For q=0 To fullmag MoveEntity bullet(q),.01,.03,2 Next ;Ammo count ammocount=100-t If t=100 Then t=1 reload=1 EndIf ;Reloading If KeyHit(19)=True Then t=1 reload=0 EndIf ;Gravity TranslateEntity cam,0,-.35,0 ;Velocity/Jump If KeyHit(54)=True And CountCollisions(cam)=True Then velocity#=1 If Not KeyHit(54)=True Then velocity#=velocity#-.008 If velocity#<-.1 Then velocity#=-.1 TranslateEntity cam,0,velocity#,0 ;Checking for collisions UpdateWorld RenderWorld If reload=0 Then Text 0,10,"Ammo: "+ammocount Else Text 0,10,"Ammo: 0" EndIf If reload=1 Then Text GraphicsWidth()/2,20,"Press R To Reload",1,1 Text GraphicsWidth()/2,GraphicsHeight()/2,"(o)" Flip Wend End