TGC Codebase Backup



"Underwater World" by tlalte uctli

9th May 2004 4:05
Summary

An "underwater" scene with drifting particles



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    ```````````````````````````````````````````````````````````````````
rem LOADS... BABY
```````````````````````````````````````````````````````````````````
rem basic stuff
Backdrop on
Set camera range 1,5000
Color Backdrop RGB(0,0,128)
hide mouse

autocam off
Fog on
Fog distance 4000
Fog color RGB(0,0,128)

rem player object
make object sphere 1, 15
position object 1, 0,0,0

rem Create 19 spheres and place randomly
rem ... this will be the "stuff" that floats down through the water
For x = 2 to 20
Make object sphere x,3
Position object x,Rnd(1000),Rnd(1000),Rnd(1000)
Next x
rem "driftcount#" will is a switch I invented to make the "drift"
rem ... loop realize when all the particles have been drifted once.
driftcount#=0

```````````````````````````````````````````````````````````````````
rem MAIN LOOP... SCHWHA
```````````````````````````````````````````````````````````````````

Do
   playerlife#=100


   Rem Store Object angle Y in aY#
   aY# = Object angle Y(1)
   Rem Control input for camera
   If Upkey()=1 then Move object 1,10
   If Leftkey()=1 then Yrotate object 1,Wrapvalue(aY#-5)
   If Rightkey()=1 then Yrotate object 1,Wrapvalue(aY#+5)
   If Downkey()=1 then Move object 1,-10
   Rem get player object position and store in X# and Z#
   X# = Object position x(1)
   Z# = Object position z(1)
   Rem get new camera position and store in cZ# and cX#
   cZ# = Newzvalue(Z#,aY#-180,100)
   cX# = Newxvalue(X#,aY#-180,100)
   Rem position camera
   Position Camera cX#,100,cZ#
   Rem point the camera at the player object
   Point camera X#,50,Z#

   rem "Drift the Stuff"
   while driftcount#=0
      for x = 2 to 20
      yx#=object position y(x)
      xx#=object position x(x)
      zx#=object position z(x)
      if x=20 then x=2
      if x=20 then driftcount#=1
      position object x,xx#,(yx#-1),zx#
      if yx#<0 then position object x,rnd(1000),1000,rnd(1000)
      next x
   endwhile
   rem end of "Drift the Stuff"

   Rem Refresh Screen
   Sync
Loop