Move a Bullet in your 3d world

Share your advanced PureBasic knowledge/code with the community.
WolfgangS
Enthusiast
Enthusiast
Posts: 174
Joined: Fri Apr 25, 2003 3:30 pm

Move a Bullet in your 3d world

Post by WolfgangS »

Hi Community
If you want a straight flying bullet you can use this formulas:

Code: Select all

If ExamineMouse()
   MouseX = -MouseDeltaX()/2
   MouseY = -MouseDeltaY()/2
   CameraDirectionX+MouseX
   CameraDirectionY+MouseY
   If MouseButton(1)   ; left MouseButton (nervous trigger finger ;)
     ; get the start coordinates 
     LocateX=CameraX(#YourCam)
     LocateY=CameraY(#YourCam)
     LocateZ=CameraZ(#YourCam)
     
     ; and calculate the deltaXYZ coordinate just one time!
     deltaY= gcos(CameraDirectionX) * gcos(CameraDirectionY) * Speed
     deltaX=-gsin(CameraDirectionX) * gcos(CameraDirectionY) * Speed
     deltaZ= gsin(CameraDirectionY)                          * Speed 
   Endif
Endif

and then and move the shot with the calculated values...

Code: Select all

If active
   LocateX + deltaX
   LocateY + deltaY
   LocateZ + deltaZ
   EntityLocate(#bullet,LocateX,LocateY,LocateZ)
EndIf



      RotateCamera(#YourCam, MouseX, MouseY,0)
      RenderWorld()

Updated for 3.70 ;)

I hope this is understandable.
MFG
WolfgangS
Last edited by WolfgangS on Wed Jun 11, 2003 11:39 pm, edited 2 times in total.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Forgot bullet time function ;)
Fred
Administrator
Administrator
Posts: 18234
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

You should use EntityLocate() instead of old MeshLocate(). A mesh is no more a movable object...
WolfgangS
Enthusiast
Enthusiast
Posts: 174
Joined: Fri Apr 25, 2003 3:30 pm

It isn´t working anymore with 3.70

Post by WolfgangS »

Hi !
i figured out the formulas aren´t working with PB 3.70 anymore. I have no clue what happend.
You can get a small example here: www.schliess.com/stuff/8_3.zip and check the formulas for yourself.

Do have anyone else has a working example of a shot in a 3d Room ?

MFG
:cry: WolfgangS
Post Reply