3Dized Cube Movement with FX by Trek13th May 2005 17:57
|
---|
Summary Two cubes randomly move with FX packed background. Description This was a 3D demo I threw together in about 45 minutes using no external sources. It basically allows two cubes to randomly bounce off the sides of the screen while a background in the back twirls and changes color and, if you want, displays a static effect. To activate the static, get rid of the remstart and remend commands except the ones at the top surrounding the credits. It has limited remarks that you may find helpful if you want to use it in your production. I have the idea that it could easily be used in some sort of game so if you want to use it feel free to do so. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com remstart ................................................. . 3Dized Cube Movement . . by . . Trek Software . . http://roborangers.home.comcast.net/Trek.html . ................................................. remend ` Setup system specifics sync on : sync rate 40 autocam off hide mouse ` Setup camera position camera 0,0,0 point camera 0,0,5 ` Setup blue cube make object cube 1,.2 position object 1,0,0,5 color object 1,rgb(0,0,255) lock object on 1 ` Setup red cube make object cube 2,.2 position object 2,3.8,0,5 color object 2,rgb(255,0,0) lock object on 2 ` Setup one of the rotating backgrounds make object cube 3,5 position object 3,0,0,5 color object 3,rgb(0,0,0) ` Setup another of the rotating backgrounds make object cube 4,5 position object 4,0,0,5 color object 4,rgb(0,0,0) yrotate object 4,30 remstart ` Setup one of the static making cubes make object cube 5,5 position object 5,0,0,5 color object 5,rgb(0,0,0) yrotate object 5,120 ` Setup another of the static making cubes make object cube 6,5 position object 6,0,0,5 color object 6,rgb(0,0,0) yrotate object 6,90 remend yellow=rgb(255,255,0) orange=rgb(255,155,0) make light 1 set point light 1,0,0,5 color light 1,yellow set light range 1,4 make light 2 set point light 2,0,0,5 color light 2,orange set light range 2,4 set ambient light 10 color backdrop rgb(0,0,0) ` Randomize directions. Wait 10 so that they'll be different. Otherwise ` we get the exact same number. dir1=rnd(3)+1 wait 10 dir2=rnd(3)+1 ` Initialize background variables c2rtate=30 c3rtate=120 c4rtate=90 rem "yrotate object 1,90" = right rem "yrotate object 1,270" = left rem "yrotate object 1,90 : zrotate object 1,90" = up rem "yrotate object 1,90 : zrotate object 1,270" = down rem 3.8 = right border rem -3.8 = left border rem 3 = top border rem -3 = bottom border ` Setup initial direction for blue cube if dir1=1 then yrotate object 1,90 if dir1=2 then yrotate object 1,270 if dir1=3 then yrotate object 1,90 : zrotate object 1,90 if dir1=4 then yrotate object 1,90 : zrotate object 1,270 ` Setup initial direction for red cube if dir2=1 then yrotate object 2,90 if dir2=2 then yrotate object 2,270 if dir2=3 then yrotate object 2,90 : zrotate object 2,90 if dir2=4 then yrotate object 2,90 : zrotate object 2,270 do ` Get original values of the directions so that if collision occurs, ` the cube doesn't continue going the same way. olddir1=dir1 olddir2=dir2 ` Move both cubes move object 1,.1 move object 2,.1 ` Control blue cube physics if object position x(1)>3.8 or object position x(1)<-3.8 or object position y(1)>3 or object position y(1)<-3 move object 1,-.1 Randomize timer() dir1=rnd(3)+1 while dir1=olddir1 dir1=rnd(3)+1 endwhile if dir1=1 then yrotate object 1,90 : zrotate object 1,30 if dir1=2 then yrotate object 1,270 : zrotate object 1,110 if dir1=3 then yrotate object 1,90 : zrotate object 1,290 if dir1=4 then yrotate object 1,270 : zrotate object 1,320 endif ` Control red cube physics if object position x(2)>3.8 or object position x(2)<-3.8 or object position y(2)>3 or object position y(2)<-3 move object 2,-.1 Randomize timer() dir2=rnd(3)+1 while dir2=olddir2 dir2=rnd(3)+1 endwhile if dir2=1 then yrotate object 2,90 : zrotate object 2,30 if dir2=2 then yrotate object 2,270 : zrotate object 2,110 if dir2=3 then yrotate object 2,90 : zrotate object 2,290 if dir2=4 then yrotate object 2,270 : zrotate object 2,320 endif ` Control rotating background 1 crtate=crtate+2 : if crtate=360 then crtate=0 color=color+1 color2=color2+2 color3=color3+3 color object 3,rgb(color,color2,color3) yrotate object 3,crtate ` Control rotating background 2 c2rtate=c2rtate+2 : if c2rtate=360 then c2rtate=0 2color=2color+4 2color2=2color2+1 2color3=2color3+2 color object 4,rgb(2color,2color2,2color3) yrotate object 4,c2rtate remstart ` Control static making cube 1 c3rtate=c3rtate+2 : if c3rtate=360 then c3rtate=0 3color=3color+2 3color2=3color2+4 3color3=3color3+3 color object 5,rgb(3color,3color2,3color3) yrotate object 5,c3rtate ` Control static making cube 2 c4rtate=c4rtate+2 : if c4rtate=360 then c4rtate=0 4color=4color+12 4color2=4color2+14 4color3=4color3+13 color object 6,rgb(4color,4color2,4color3) yrotate object 6,c4rtate remend set point light 1,object position x(1), object position y(1), object position z(1) set point light 2,object position x(2), object position y(2), object position z(2) sync loop |