Jump to content
  • Advertisement
Sign in to follow this  
IN1L8

how do i make the direction change?

This topic is 4618 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am programming in Blitz 3d and i am trying to make a character go forward and back when you press up and down and turn and change direction when you press left and right. i got my character to turn, but how do i make it change in the direction it's turning? here's my code:
;;INITIALIZATION;;

;Graphics
Graphics3D 800,600,0,1
SetBuffer BackBuffer()

;creates camera and light, puts light at a different angle
camera=CreateCamera()
light=CreateLight()
RotateEntity light,25,75,60

;creates brush and sets color for painting
brush=CreateBrush()
BrushColor brush,120,64,0

;player mesh, rotation and location of the mesh, and its color
player=LoadMesh("C:\Program Files\Milkshape 3D 1.7.0\player_model1.b3d")
RotateMesh player,0,180,0
PaintMesh player,brush
PositionEntity player,0,0,MeshDepth(player)*10


;;MAIN GAME CODE;;

;While not pressing Esc
While Not KeyDown(1)
x#=0
y#=0
z#=0

pitch#=0
yaw#=0
roll#=0

;If Up key is pressed, move player forward
If KeyDown(200)=True Then z#=0.5

TranslateEntity player,x#,y#,z#

;If Down key is pressed, move player backward
If KeyDown(208)=True Then z#=-0.5

TranslateEntity player,x#,y#,z#

;If Left key is pressed, rotate player towards the left
If KeyDown(203)=True Then yaw#=yaw#+1 And

TurnEntity player,pitch#,yaw#,roll#

;If Right key is pressed, rotate player towards the right
If KeyDown(205)=True Then yaw#=yaw#-1 And

TurnEntity player,pitch#,yaw#,roll#

RenderWorld
Text 0,0,"PRESS ESC TO QUIT"
Flip
Wend
End

;If Esc is pressed, exit the program
If KeyDown(1)
End
EndIf 

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by IN1L8
(how do i make this a scroll list?)
Use <source> </source> tags (replacing < and > with [ and ] )

Share this post


Link to post
Share on other sites
i don't have a problem with making it rotate, i just can't get it to turn and then move in the direction that it's turning to. whenever i'm pressing forward it goes forward, but when i press left or right while it's moving it just keeps going in the same direction as before instead of going in a new direction

Share this post


Link to post
Share on other sites
I don't know Blitz3d, but my guess is that TranslateEntity moves an entity in the global coordinate system, not relative to the direction it's facing. There might another Blitz3d function for that. If there isn't, you'd have to do the math manually. The link which Cosmic R gave would be a good start for that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!