; MoveEntity Example ; ------------------ Graphics3D 640,480,0,2 SetBuffer BackBuffer() SeedRnd MilliSecs() camera=CreateCamera() PositionEntity camera,0,0,-10 light=CreateLight() RotateEntity light,45,45,0 ; A ship we can fly around ship=CreateCone(16) EntityColor ship,0,200,255 While Not KeyDown(1) ; Reset movement values each frame - otherwise the ship would never stop x#=0 y#=0 z#=0 ; Cursor keys and A/Z set this frame's movement If KeyDown(203) Then x=-0.1 If KeyDown(205) Then x=0.1 If KeyDown(208) Then y=-0.1 If KeyDown(200) Then y=0.1 If KeyDown(44) Then z=-0.1 If KeyDown(30) Then z=0.1 ; MoveEntity moves along the ship's own LOCAL axes: z is always "forward, ; wherever the ship is pointing". Compare TranslateEntity (world axes) ; and PositionEntity (absolute coordinates). MoveEntity ship,x,y,z ; Space rotates the ship randomly - the same keys then move it in NEW directions If KeyHit(57) Then RotateEntity ship,Rnd(0,360),Rnd(0,360),Rnd(0,360) RenderWorld Text 0,0,"Cursors/A/Z: move Space: rotate randomly Esc: exit" Text 0,20,"MoveEntity ship,"+x+","+y+","+z+" (local axes)" Flip Wend End