im not quite sure but the code for waves is probably by "Ric" and modified by me as well as all the rest is by me.
* For easier adaptation to your own projects, its all made of Subs
**You need the attachment images as textures
put the image folder in the same place as your project is.
Rem ***** Main Source File *****
fog on : fog distance 1500
GOSUB Level1
GOSUB camera_Setup
Sync on
DO
GOSUB wtrWaves
GOSUB camera_Free_Loop
text 0,0,str$(screen fps())
sync
LOOP
Level1:
Cam_Start_X# = 2500.0
Cam_Start_Y# = 100.0
Cam_Start_Z# = 2500.0
`------------LOAD WATER---------------
`size of wave area
wtrMatRows = 50
wtrMatColumns = 50
`dipper1 x,z coordinates:
wtrDipx1 = 29 `****x TILE NUMBER WHICH THE WAVE CONTROLLER IS***
wtrDipz1 = 29 `****y TILE NUMBER WHICH THE WAVE CONTROLLER IS***
`dipper2 x,z coordinates:
wtrDipx2 = 30
wtrDipz2 = 10
wtrElasticity# = 0.002
wtrDamping# = 0.995
waveY# = -100
wtrNum=wtrMatRows*wtrMatColumns
dim wtrObNum(wtrMatRows+1,wtrMatColumns+1)
dim wtrV#(wtrMatRows,wtrMatColumns)
REM LOAD IMAGES
imgWavesS = free_image()
tmrWaves# = imgWavesS
for a = 0 to 31
imgWaves = free_image()
LOAD IMAGE "water/waves0"+str$(a)+".bmp", imgWaves, 1
next a
mat = free_matrix()
make matrix mat,wtrMatRows*100,wtrMatColumns*100,wtrMatRows,wtrMatColumns
`prepare matrix texture mat,imgWater,1,1
ghost matrix on mat,2
for x=1 to wtrMatRows
for z=1 to wtrMatColumns
wtrObNum(x,z)=wtrOb
wtrOb=wtrOb+1
next z
next x
dim wtrFixed(wtrMatRows*wtrMatColumns)
wtrFixed(wtrObNum(wtrDipx1,wtrDipz1))=1
wtrFixed(wtrObNum(wtrDipx2,wtrDipz2))=0
RETURN
wtrWaves:
tmrWaves# = tmrWaves# + 0.3 `how fast the texture animation is
if tmrWaves# => imgWavesS+31 then tmrWaves# = imgWavesS
prepare matrix texture mat,tmrWaves#,1,1
if waveY# => 50 then waveYinc# = -0.5 `how big the wave is
if waveY# =< -50 then waveYinc# = 0.5 `how big the wave is
waveY# = waveY# + waveYinc#
`if keystate(18)=1 then waveY#=waveY#+10
`if keystate(19)=1 then waveY#=waveY#-10
if wtrFixed(wtrObNum(wtrDipx1,wtrDipz1))=1
set matrix height mat,wtrDipx1,wtrDipz1,waveY#
endif
for x=1+1 to wtrMatRows-1
for z=1+1 to wtrMatColumns-1
`check x+1 height
if x<wtrMatRows
distxp1#=get matrix height(mat,x+1,z)-get matrix height (mat,x,z)
endif
`check x-1 height
if x>1
distxm1#=get matrix height(mat,x-1,z)-get matrix height (mat,x,z)
endif
`check z+1 height
if z<wtrMatColumns
distzp1#=get matrix height(mat,x,z+1)-get matrix height (mat,x,z)
endif
`check z-1 height
if z>1
distzm1#=get matrix height(mat,x,z-1)-get matrix height (mat,x,z)
endif
`calculate vector some of heights adjacent to object
`and make this proportional to the objects acceleration
vectorsum#=distxp1#+distxm1#+distzp1#+distzm1#
a#=vectorsum#*wtrElasticity#
`increase object's velocity by it's acceleration amount
wtrV#(wtrObNum(x,z))=wtrV#(wtrObNum(x,z))+a#
if wtrFixed(wtrObNum(x,z))=0
`reposition object
set matrix height 1,x,z,get matrix height(1,x,z)+wtrV#(wtrObNum(x,z))
wtrV#(wtrObNum(x,z))=wtrV#(wtrObNum(x,z))*wtrDamping#
endif
next z
next x
update matrix mat
RETURN
`--------------------------------------------------------------
`--------------------------------------------------------------
`-----------------SETUP CAMERA DUMMY OBJECT--------------------
`--------------------------------------------------------------
`--------------------------------------------------------------
camera_Setup:
REM CAMERA SETUP
dummyCam = free_object()
MAKE OBJECT BOX dummyCam, 5, 5, 5 : HIDE OBJECT dummyCam
REM POSITION THE START CAMERA
POSITION OBJECT dummyCam, Cam_Start_X#, Cam_Start_Y#, Cam_Start_Z#
camMoveSpeed# = 1.0 : mouseSpeed = 5
RETURN
`--------------------------------------------------------------
`--------------------------------------------------------------
`----------------------FREE CAMERA LOOP------------------------
`--------------------------------------------------------------
`--------------------------------------------------------------
camera_Free_Loop:
if shiftkey() > 0
inc camMoveSpeed#, 0.1
if camMoveSpeed# => 10.0 then camMoveSpeed# = 10.0
else
if camMoveSpeed# > 1.0
dec camMoveSpeed#, 0.1
if camMoveSpeed# =< 1.0 then camMoveSpeed# = 1.0
endif
endif
if keystate(17)=1 then MOVE OBJECT dummyCam, camMoveSpeed#
if keystate(30)=1 then MOVE OBJECT LEFT dummyCam, camMoveSpeed#
if keystate(31)=1 then MOVE OBJECT dummyCam, -camMoveSpeed#
if keystate(32)=1 then MOVE OBJECT RIGHT dummyCam, camMoveSpeed#
rem camera rotation
camAngX# = wrapvalue((mousemovey() / mouseSpeed) + camAngX#)
camAngY# = wrapvalue((mousemovex() / mouseSpeed) + camAngY#)
rem stops mouse from going upside down
if camAngX# > 80 and camAngX# < 180 then camAngX# = 80
if camAngX# > 180 and camAngX# < 310 then camAngX# = 310
ROTATE OBJECT dummyCam, camAngX#, camAngY#, object angle z(dummyCam)
camPosX# = object position x(dummyCam)
camPosY# = object position y(dummyCam)
camPosZ# = object position z(dummyCam)
camAngX# = object angle x(dummyCam)
camAngY# = object angle y(dummyCam)
camAngZ# = object angle z(dummyCam)
POSITION CAMERA 0, camPosX#, camPosY#, camPosZ#
ROTATE CAMERA 0, camAngX#, camAngY#, object angle z(dummyCam)
RETURN
`---------------------------------------------------------
Function free_image()
Repeat
Inc i
Until Image Exist(i) = 0
EndFunction i
`---------------------------------------------------------
Function free_matrix()
Repeat
Inc i
Until Matrix Exist(i) = 0
EndFunction i
`---------------------------------------------------------
Function free_object()
Repeat
Inc i
Until Object Exist(i) = 0
EndFunction i
`---------------------------------------------------------