TGC Codebase Backup



dinamic world by pavelsv1982

7th Feb 2011 6:47
Summary

my great dinamic world beta



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    dim heightmatrix(500,500)
   `Set Up Screen
      set display mode 1024,768,32
      sync on
      sync rate 100
      hide mouse
load sound "rain.wav",1
play sound 1
loop sound 1
   `Setup Camera
      autocam off
      position camera 1100,35,1000
      yrotate camera 180
      set camera range 1,20000
      set camera fov 70

      `Make Reflection Camera
      make camera 1
      set camera range 1,1,20000
      set camera fov 1,70
      set camera to image 1,5,512,512
      set camera aspect 1,1.35
      `load image "data/waves.jpg",5

  `Make Skybox
      make object box 1,15000,15000,15000
      load image "data\skyday.bmp",3
      load image "data\skynight.bmp",9
      texture object 1,3
      set object light 1,0
      set object 1,1,0,0,0,0,0,0
      set object texture 1,3,1,1
      position object 1,0,0,0



   rem Create matrix
make matrix 1,4000,4000,501,501
randomize matrix 1,5.0
for x=1 to 501
   for z=1 to 501
      set matrix normal 1,x,z,0,0.9-(rnd(5)/10.0),0
   next z
next x



rem создание дождя
print "создание дождя"
sync
for er=1000 to 1250
make object box er,0.05,0.05,1
rotate object er,90,0,0
position object er,camera position x()-25+rnd(50),camera position y()-25+rnd(500),camera position z()-25+rnd(50)
next er

rem создание облаков
load image "cloud\cloud.bmp",2000
for rer=2001 to 3000
make object plain rer, 512,512

texture object rer,2000
xxrer1=-5000+rnd(10000)
yyrer1=300
zzrer1=-5000+rnd(10000)
position object rer,xxrer1,yyrer1,zzrer1
POINT OBJECT rer,camera position x(),camera position y(),camera position z()
rem set object light rer,0
ghost object on rer
next rer

load image "texture/grassT.bmp",1
PREPARE MATRIX TEXTURE 1, 1,1,1

rem первая площадка и главная
print "создание материка"
sync
dim height(500,500)
for t=0 to 150
for alf=0 to 360
a=int(250+t*cos(alf))
b=int(250+t*sin(alf))
for dx=0 to 20
for dy=0 to 20
a1=a+dx-10
b1=b+dy-10
height(a1,b1)=30
height1=GET MATRIX HEIGHT(1, a1,b1)
SET MATRIX HEIGHT 1, a1, b1, height(a1,b1)
next dy
next dx
SET MATRIX HEIGHT 1, 126, 126, 200
next alf
next t
update matrix 1

rem первая площадка и главная
for xc=1 to 3
for yc=1 to 3
rr=rnd(20)*4
for t=0 to rr
for alf=0 to 360
a=int(100+rnd(100)*(xc-1)+t*cos(alf))
b=int(100+rnd(100)*(yc-1)+t*sin(alf))
for dx=0 to 20
for dy=0 to 20
a1=a+dx-10
b1=b+dy-10
height(a1,b1)=30
height1=GET MATRIX HEIGHT(1, a1,b1)
SET MATRIX HEIGHT 1, a1, b1, height(a1,b1)
next dy
next dx
SET MATRIX HEIGHT 1, 126, 126, 200
next alf
next t
update matrix 1
next yc
next xc

rem деревья и трава.
for rte=4000 to 4400
print rte
sync
load object "tries\q\oak tree summer.x",rte
rem load object "tries\qqq\plant16.x",rte+1
position object rte,500+rnd(2000),30,500+rnd(2000)
rem position object rte+1,500+rnd(2000),30,500+rnd(2000)
rem scale object rte,1000,1000,1000
rem scale object rte+1,200,200,200
rem ghost object on rte
rem set object light rte,0
next rte





  rem солнце
   make object plain 5,1024,1024
   load image "sun\sun1.bmp",10
   texture object 5,10
   ghost object on 5
   set object light 5,0
  rem луна
  make object sphere 6,256
  load image "sun\moon.bmp",11
  texture object 6,11
  set object light 6,0


   `Make Water Object
      load image "data/waves.jpg",6
      make object plain 2,10000,10000
      xrotate object 2,270
      texture object 2,0,5
      texture object 2,1,6
      load effect "Effects/water.fx",1,0
      set object effect 2,1
      ghost object on 2,4
         u=10
         v=10

         dim rty(250)

    do
print "цикл"
rem двигаем облака

for rer=2001 to 3000
xxrer1=object position x(rer)+1
yyrer1=object position y(rer)
zzrer1=object position z(rer)
position object rer,xxrer1,yyrer1,zzrer1
POINT OBJECT rer,camera position x(),camera position y(),camera position z()
if xxrer1>10000
xxrer1=-5000
endif
next rer

if rain =1
lrain=lrain-1
endif

if rain=0
wrain=wrain-1
endif

rem двигаем дождь
for er=1 to 250
move object er+1000,5
if OBJECT POSITION y(er+1000)<=0
position object er+1000,rnd(30)-15+camera position x(),300+camera position y(),camera position z()+rnd(30)-15
endif
next er
 if rain=0 and wrain<0
  lrain=2000
  rain=1
  play sound 1
  loop sound 1
  for we=1000 to 1250
   show object we
  next we
 endif


 if lrain<0 and rain =1
wrain=2000
 rain=0
 stop sound 1
 for we=1000 to 1250
  hide object we
 next we
endif

  alfa1#=alfa1#+1
if alfa1#>=360 then alfa1#=0
xx1=6000*sin(alfa1#)
xx2=6000*sin(alfa1#+180)
yy1=2000*sin(alfa1#+180)
yy2=2000*sin(alfa1#)
zz1=cos(alfa1#+180)*6000
zz2=cos(alfa1#)*6000
print alfa1#
rem смена дня и ночи
if alfa1#>180
texture object 1,3
else
texture object 1,9
endif



position object 5,xx1,yy1,zz1
point object 5, camera position x(),camera position y(),camera position z()
position object 6,xx2,yy2,zz2

            `Control Camera
         cr#=0
         cf#=0
      if rightkey()=1 or KEYSTATE(32)=1 then cr#=-2
      if leftkey()=1 or KEYSTATE(30)=1 then cr#=2
      if upkey()=1 or KEYSTATE(17)=1 then cf#=2
      if downkey()=1 or KEYSTATE(31)=1 then cf#=-2
         ncr#=curvevalue(cr#,ncr#,5)
         ncf#=curvevalue(cf#,ncf#,5)
         cx#=cx#+mousemovey()*0.2
         cy#=cy#+mousemovex()*0.2
      if cx#>80 then cx#=80
      if cx#<-80  then cx#=-80
         ncx#=curveangle(cx#,ncx#,2)
         ncy#=curveangle(cy#,ncy#,2)
      move camera ncf#
         rotate camera 0,wrapvalue(ncy#-90),0
            move camera ncr#
         rotate camera 0,wrapvalue(ncy#+90),0
      rotate camera ncx#,ncy#,0

   `Move Camera 1 To Camera 0 Pos and invert the X angle
      `position camera 1,camera position x(),object position y(2)-(camera position y()-object position y(2)),camera position z()
      position camera 1,camera position x(),camera position y(),camera position z()
      rotate camera 1,-camera angle x(),camera angle y(),camera angle z()

   `Move Water Around
      ro#=wrapvalue(ro#+0.05)
      position object 2,500+sin(ro#)*100.0,20,500+cos(ro#)*100.0


      sync

     loop