TGC Codebase Backup



Spin Camera Around by TheOneRing

22nd Oct 2003 11:42
Summary

Function to spin the camera around a location



Description

This function will spin the camera around a point in space a specific number of revolutions at a specified speed.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    function SpinCameraAround(targetX#, targetY#, targetZ#, DistanceFromObject#, Speed#, CameraNumber, NumRevolutions)

   for index = 1 to NumRevolutions

      angle# = 0
      while angle# < 360
         angle# = angle# + Speed#

         xPos# = targetX# + cos(angle#) * DistanceFromObject#
         yPos# = targetY#
         zPos# = targetZ# + sin(angle#) * DistanceFromObject#

         position camera CameraNumber, xPos#, yPos#, zPos#
         point camera CameraNumber, targetX#, targetY#, targetZ#

         sync
      endwhile

   next index

endfunction