TGC Codebase Backup



Elite camera handling by Shogun Blackbrunei

11th Feb 2005 9:51
Summary

Camera movement where the camera rotates AROUND a model, you can turn left/right and up/down too!



Description

Camera movement where the camera rotates AROUND a model, you can turn left/right and up/down too! Well commented and also very easily adjustable! The camera points at the main model and even has a angle stop so you don't keep on turning the whole time! Very usefull for about any game!



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `Camera handling
`Made by: Sei-I-Tai Shogun: Blackbrunei
`Free to use in any program, have fun
sync on
sync rate 60

`make a main model
make object sphere 2,0.5

`camera variables
#Yang=180
#Xang=20

`main loop
do

`mouse handling
`if the mouse is on the side of the screen, we scroll our camera using the variable #Yang
 if mousex() > screen width() - 20
  #Yang=wrapvalue(#Yang + 1)
 endif
 if mousex() <  20
  #Yang=wrapvalue(#Yang - 1)
 endif
 `and we do the same but now we scroll up
 if mousey() > screen height() - 20
  #Xang=wrapvalue(#Xang - 1)
  if #Xang > 50
   #Xang = 0
  endif
 endif
 if mousey() <  20
  #Xang=wrapvalue(#Xang + 1)
  if #Xang > 50
   #Xang = 50
  endif
 endif

 `camera handling
 `position camera slightly above our model
 position camera object position x(2),object position y(2)+0.5,object position z(2)
 `rotate it to the specified angles
 yrotate camera #Yang
 xrotate camera #Xang
 `move it back so we have some distance
 move camera -4
 `finally point it at our main model
 point camera object position x(2),object position y(2),object position z(2)

sync
loop