TGC Codebase Backup



POiNT CAMERA by Louiz ofRohr

25th Aug 2004 14:16
Summary

Camera always points to object in interactive movement.



Description

A simple example of a basic code used in some animations or games with small ground. The camera keeps itself, in this example, on middle of ground, at 500 points to _y. You move a sphere around the ground and the camera points to this. Take a good benefit.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `<<<<<<<<<<<<< CÂMERA FiXA A UM PONTO >>>>>>>>>>>>>´
    REM _ _ _ _UM CÓDiGO BASE DE LOUiZ_ _ _ MER
    REM _ _ _ _A SOURCE CODE By LOUiZ_ _ _ MER
`<<<<<<<<<<<<<    POiNT CAMERA      >>>>>>>>>>>>>>>´

sync on
sync rate 60
hide mouse
`CORES PRÉ-DEFiNiDAS (Define Colours)
vermelho = rgb(200,0,0)
preto = rgb(0,0,0)
`XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

`EFEiTO FOG A 2000 DA CÂMERA (Fog at 2000 from camera)
Fog on
fog distance 2000
fog color preto
`XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

`CENÁRiO (Ground)
make matrix 1, 5000, 5000, 30, 30
position matrix 1, 0, 0, 0
`XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

`PERSONAGEM (Character)
make object sphere 1, 50
color object 1, vermelho
position object 1, 2500, 30, 2500
`XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

`POSiÇÃO iNiCiAL DA CÂMERA (Camera's initial position)
position camera 2500, 500, 2500
`XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

`AÇÕES CONSTANTES (Main Loop)
DO
`CONTROLA O PERSONAGEM (Character controls)
if upkey()=1 THEN move object 1, 5
if downkey()=1 THEN move object 1, -5
if leftkey()=1 THEN turn object left 1, 5
if rightkey()=1 THEN turn object right 1, 5
`XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

`POSiÇÃO DO PERSONAGEM (Character position)
PX# = object position x(1)
PY# = object position y(1)
PZ# = object position z(1)
point camera PX#, PY#, PZ#
`XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

`ATUALiZA A TELA (Update screen)
sync
`XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

`REPETE AS AÇÕES EDSDE O "DO" (Back to "DO" and play)
LOOP
`XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX