Wave Program by zodiac15th Mar 2006 13:40
|
---|
Summary Wave program using sin function to create waves. You can "swim" in the "water" using arrow keys Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com cls:sync on:sync rate 100 `coded by kevin forbes `Beginning variables input "Wave Height(1 to 70): ", mh input "Wave Realism(1 to 20): ",wr input "Wave Speed(1 to 4): ", speed print:print:print:print print "Toggle Wireframe with 'a'" print "Turn Left and Right with corresponding Arrow Keys" print "Pitch Camera up and down by pressing/holding space and pushing the corresponding arrow key" print:print:print print "Press any key to continue":suspend for key cls:print "Background Color:" input "Red Percentage(x of 255): ", r input "Green Percentage(x of 255): ", g input "Blue Percentage(x of 255): ", b print:print:print:print "Press any key to continue" suspend for key `Matrix and texture make matrix 1, 500.0, 500.0, 50, 50 update matrix 1 camup = 2:camturn = 2:camx#=250:camz#=250 color backdrop rgb(r, g, b) `Main Do...Loop do `Camera movement if upkey()=1 move camera 1 camx#=camera position x() camz#=camera position z() endif if downkey()=1 move camera -1 camx#=camera position x() camz#=camera position z() endif if spacekey()=1 if downkey()=1 camup = camup + 1 xrotate camera camup if camup > 359 then camup = 1 endif if upkey()=1 camup = camup - 1 xrotate camera camup if camup < 1 then camup = 359 endif endif if rightkey()=1 camturn = camturn + 1 yrotate camera camturn if camturn > 359 then camturn = 1 endif if leftkey()=1 camturn = camturn - 1 yrotate camera camturn if camturn < 1 then camturn = 359 endif `Creation of waves for z = 0 to 50 for x = 0 to 50 h#=sin(z*10+n)*mh h#=h#+(sin(x*10+s)*mh) h#=h#/2.0 set matrix height 1, x, z, h# next x next z update matrix 1 `Camera bobbing cammove#=sin((camz#+n))*mh+5 cammove#=cammove#+(sin((camx#+s))*mh+5) cammove# = cammove#/2.0 position camera camx#, cammove#, camz# `Toggle wireframe if inkey$()="a" if matrix wireframe state(1)=0 then set matrix wireframe on 1:wait 100 endif if inkey$()="a" if matrix wireframe state(1)=1 then set matrix wireframe off 1:wait 100 endif `Increased variables n=n+speed:s=s-speed set mipmap mode 2 `Loop sync:loop |