I can't seem to get my "shooting" code to work.. Please take a look and help me out. I think it might be something with the Update(renderworld) command but I'm not sure. Also, I'd like some good fog, if anyone has any recommendations?
Type Timer Field start Field timeOut Field vel_start#;=90 Field vel_down#;=-2 End Type ;System Global AppFPS =45 Global screen_width% = 1024 Global screen_height% = 768 Global screen_halfwidth% = screen_width/2 Global screen_halfheight% = screen_height/2 Global camHeight#=4.5 ; default height of the camera behind player Global camDist#=-7 ; default distance of the camera behind player Global dest_xang# Global dest_yang# Global pl_gravity#=-.5 Global pl_jump=0 Global Jump_Move#=0 Global Move_For_Back# Global Move_Left_Right# Global Move_Slow#=.1 Global which_one=0 Global player Global playerattack Global revolverman Global shotgun Global revolver ;CONST Const C_PLAYER=1, C_LEVEL=2, C_BULLET=3,C_ENEMY=4 AppTitle "Italia" HidePointer ;Screen Graphics3D screen_width,screen_height,32,1 SetBuffer BackBuffer() CreateWorld() ;bullets Type bullettype Field entityhandle End Type Type badguytype Field entityhandle Field state End Type ;CAMERA camera =CreateCamera() ;Player Pivot plpivot=CreatePivot() EntityType plpivot, C_PLAYER ;EntityRadius plpivot,1.8,3 PositionEntity plpivot, 0, 3,0 ;Player, now a cube but you can change for a nice model ;Player=CreateCube(plpivot) ;ScaleEntity player,1,3,.7 ;MoveEntity player,0,1,0 ;EntityColor Player,255,0,255 which_one = 0 player=LoadMesh("C:\Documents and Settings\Chad\Desktop\game\mobster\player.b3d",plpivot) ScaleEntity player,.08,.08,.08 MoveEntity player,0,1,0 playerattack=LoadMesh("C:\Documents and Settings\Chad\Desktop\game\mobster\playerattack.b3d",plpivot) ScaleEntity playerattack,.08,.08,.08 MoveEntity playerattack,0,1,0 revolverman=LoadMesh("C:\Documents and Settings\Chad\Desktop\game\mobster\revolverman.b3d",plpivot) ScaleEntity revolverman,.08,.08,.08 MoveEntity revolverman,0,1,0 EntityAlpha player,1 EntityAlpha playerattack,0 EntityAlpha revolverman,0 ;Bullet Mesh bulletmesh=CreateCone() RotateMesh bulletmesh,90,0,0 ScaleEntity bulletmesh,1,.1,.1 EntityType bulletmesh, C_BULLET EntityRadius bulletmesh, 0.01 If mouse1 bullet.bullettyp New bullettype bullet\entityhandle = CopyEntity(bulletmesh) PositionEntity bullet\entityhandle, EntityX(playerattack, 1), EntityY(playerattack, 1), EntityZ(playerattack, 1) RotateEntity bullet\entityhandle, EntityPitch(playerattack, 1), EntityYaw(playerattack, 1), EntityRoll(playerattack,1) ResetEntity bullet\entityhandle EndIf For thisbullet.bullettype = Each bullettype MoveEntity thisbullet\entityhandle, 0, 0, 2 If Abs(EntityX(thisbullet\entityhandle, 1)) > 10000 FreeEntity thisbullet\entityhandle Delete thisbullet ElseIf Abs(EntityZ(thisbullet\entityhandle, 1)) > 10000 FreeEntity thisbullet\entityhandle Delete thisbullet ElseIf Abs(EntityZ(thisbullet\entityhandle, 1)) > 10000 FreeEntity thisbullet\entityhandle Delete thisbullet EndIf Next ;I'm using 2 pivots for camera controlling ;Pivot for the camera controlling ;One Front of the player, FrontPivot=CreatePivot(plpivot) PositionEntity Frontpivot,0,4,10 ;One behind player ;This pivot controlls the collisions and "finds" the right position of the camera behind player Backpivot=CreatePivot(plpivot) EntityRadius Backpivot,1 EntityType BackPivot, C_PLAYER Collisions C_PLAYER, C_LEVEL ,2,2 Collisions C_BULLET, C_ENEMY ,2,1 Collisions C_BULLET, C_LEVEL ,2,1 Collisions C_PLAYER, C_ENEMY ,1,2 ; ------------- ; Main loop ; ------------- FramePeriod = 1000 / AppFPS FrameTime = MilliSecs () - FramePeriod While Not KeyHit(1) ; -------------------------- ; Frame rate limiting ; -------------------------- Repeat FrameElapsed = MilliSecs () - FrameTime Until FrameElapsed FrameTicks = FrameElapsed / FramePeriod FrameTween# = Float (FrameElapsed Mod FramePeriod) / Float (FramePeriod) ; ----------------------- ; Update tweening ; ----------------------- For FrameLimit = 1 To FrameTicks If FrameLimit = FrameTicks Then CaptureWorld EndIf FrameTime = FrameTime + FramePeriod UpdateCamera(plpivot,MouseXSpeed(),MouseYSpeed(), Frontpivot, Backpivot, Camera) UpdatePosition(plpivot) UpdateWorld ;Possibly move below this next Next For thisbullet = Each bullettype If CountCollisions (thisbullet\entityhandle) > 0 enemyhit = EntityCollided(thisbullet\entityhandle, 3) If enemyhit = EntityCollided(thisbullet\entityhandle, 3) If enemyhit > 0 Then KillBadGuy(enemyhit) FreeEntity thisbullet\entityhandle Delete thisbullet EndIf Next RenderWorld FrameTween ; Crosshair Text screen_halfwidth%, screen_halfheight%, "+" Flip 0 Wend End Function updatecamera(ent,mxs#, mys#, pivot1, pivothatso, camera) ;ent : Player pivot ;mxs: MouseXmove ;mys: MouseYmove ;pivot1: pivot before player ;pivothatso: pivot behind player ;Camera: MoveMouse screen_halfwidth%, screen_halfheight% ; Limit of the "look up", "look down" If dest_xang + mys > 120 Or dest_xang + mys < -45 Then ; mys=0 EndIf dest_xang# = dest_xang + mys ; When the player looks up, the front pivot moves UP, when looks down the back pivot moves down TranslateEntity pivot1,0,-MYS#*.15,0 angle#= Sin(EntityPitch(camera))*6 tempkkammag#=camheight + (angle*.8) tempkkamtav#= camdist + Abs( angle) dest_yang# = dest_yang - (mxs*.5) RotateEntity ent, 0, dest_yang,0 dx#=(EntityX(pivothatso,True)-EntityX(camera,True)) *.1 dy#=(EntityY(pivothatso,True)-EntityY(camera,True)) *.9 dz#=(EntityZ(pivothatso,True)-EntityZ(camera,True)) *.1 TranslateEntity camera,dx,dy,dz PointEntity camera,pivot1 PositionEntity pivothatso,0,0,0 ResetEntity pivothatso PositionEntity pivothatso,0,tempkkammag,tempkkamtav End Function ;=========================FOG myfogtex=CreateTexture(128,128,2 Or 48) SetBuffer TextureBuffer(myfogtex) LockBuffer() For j=25 To 127 For i=25 To 127 trans=(j-48)*4 If trans<0 Then trans=0 If trans>255 Then trans=255 ;WritePixelFast i,j, GetRGB(120,50,150) Or (trans Shl 24) Next Next UnlockBuffer() SetBuffer BackBuffer() myfog=CreateCylinder(4,0,plpivot) RotateMesh myfog,0,45,9 EntityAlpha myfog,0.1 EntityFX myfog,1 EntityTexture myfog,myfogtex ScaleEntity myfog,50,25,50 FlipMesh myfog Dim myfogb(10) For i=0 To 3 myfogb(i)=CopyEntity(myfog,myfog) scale#=1+(.1*Float(i)) ScaleEntity myfogb(i),scale#,scale#,scale# EntityAlpha myfogb(i),.3*i EntityParent myfogb(i),myfog Next Function UpdatePosition(ent) ;MOVEMENT If pl_jump=0 If KeyDown(200) Or KeyDown(17) Then Move_For_Back=.3 End If If KeyDown (208) Or KeyDown(31) Then Move_For_Back=-.2 End If If KeyDown(203) Or KeyDown(30) Then Move_Left_Right=-.2 End If If KeyDown (205) Or KeyDown(32) Then Move_Left_Right=.2 End If EndIf If KeyHit(18) Then which_one=which_one+1 Select (which_one Mod 3) Case 0 EntityAlpha player,1 EntityAlpha playerattack,0 EntityAlpha revolverman,0 Case 1 EntityAlpha playerattack,1 EntityAlpha player,0 EntityAlpha revolverman,0 Case 2 EntityAlpha revolverman,1 EntityAlpha player,0 EntityAlpha playerattack,0 End Select EndIf ;If MouseHit(1) Then ; which_one=which_one+1 ; Select (which_one Mod 2) ; Case 0 ; EntityAlpha player,1 ; EntityAlpha playerattack,0 ; Case 1 ; EntityAlpha playerattack,1 ; EntityAlpha player,0 ; End Select ; EndIf If ( MouseHit(2) Or KeyHit(57)) And pl_jump=0 t.Timer = JumpTimer (1500) ;When jumps slides in the air doesn't stop quickly Move_Slow#=.999 pl_jump=1 EndIf If jump_timeout()=1 pl_jump=0 ;when goes stops quickly Move_Slow#=.1 EndIf MoveEntity ent, Move_Left_Right, Jump_Move, Move_For_Back TranslateEntity ent,0,pl_gravity,0 ;Smooth movement move_left_right = move_left_right * move_slow move_for_back = move_for_back * move_slow End Function Function JumpTimer.timer (timeOut) t.Timer = New Timer t\start = MilliSecs () t\timeOut = t\start + timeOut t\vel_start#=90 t\vel_down#=-2 Return t End Function ; Check for timeout: Function Jump_TimeOut () For test.timer= Each timer If test\timeOut < MilliSecs () Jump_move=0 Delete test Return 1 Else Jump_Move=Sin(test\vel_start#) test\vel_start=test\vel_start#- test\vel_down# Return 0 EndIf Next End Function Function CreateWorld() ;Light light=CreateLight(1,town) PositionEntity light ,0,150,0 light2=CreateLight(2) PositionEntity light2,29.5,0,44.5 ;Plan plan=CreatePlane() EntityColor plan,255,0,0 EntityType plan, C_LEVEL Function KillBadGuy(enemyhit) For thisbadguy.badguytype = Each Badguytype If enemyhit = thisbadguy\entityhandle If thisbadguy\state <> 5 thisbadguy\state = 5 ;dead EntityType thisbadguy\entityhandle, 0 RotateEntity thisbadguy\entityhandle,90,0,0 TranslateEntity thisbadguy\entityhandle, 0, -1, 0 Exit EndIf EndIf Next Endfunction