Acelepage, i have you to thank for finally getting me to do this project ive been meaning and trying to do for a while now...
Heres what ive done so far, and in the 3 and a half days left i shall try to fine tune it a bit more...
`Infinite scrolling landscape
`Made up of lots of small memblock matrices
`starts as one large matrix
`gets split up
`then converted to memblock matrices by making large memblocks and setting the heights...
`Gaussian Function adapted from code by The Comet
`Memblock matrix code adapted from code by Kevil
rem setup screen
sync on
sync rate 30
autocam off
if check display mode(1024,768,32) = 0
set display mode 800,600,16
else set display mode 1024,768,32
endif
`set window on
randomize 100`timer()
`for mesh
dim tilex(128)
dim tilez(128)
dim tilesizex#(128)
dim tilesizez#(128)
dim texture(128)
dim xpart#(128)
dim ypart#(128)
dim object(128)
time=timer()
fase#=0.00
splitx = 5
splity = 5
oldsizex = 3000
oldsizey = 3000
oldnox = 250
oldnoy = 250
newnox = (oldsizex/splitx)/12
newnoy = (oldsizey/splity)/12
midrow = 3
midcol = 3
dim mat(splitx*splity+1,4)
dim oldheight#(oldnox,oldnoy)
dim midpoint(splitx*splity+1,2)
dim lodheight#(splitx*splity+1,newnox,newnoy)
dim move(5)
mat = 1
makenorm(mat,oldsizex,oldsizey,oldnox,oldnoy,25,100)
splitmatrix(mat,splitx,splity,oldsizex,oldsizey,oldnox,oldnoy)
`texturenorm(3,3)
memblock(600,600,5,5)
waves(30,0)
set camera range 0,1,10000
position camera 0,1500,200,1500
position mouse 512,384
do
text 0,0,str$(screen fps())
gosub movematrices
`movematrices(5,5)
`text 0,10,str$(position)
remstart
`waves etc
dt#=(timer()-time)/1000.0
time=timer()
positionmatrix(25,0,5+(sin(fase#)),0)
fase#=fase#+(45*dt#)
remend
elapsedtime#=(timer()-start)/1000.0
start=timer()
xrot#=camera angle x(0)
if mouseclick() = 1
inc speed#,1000*elapsedtime#
if speed#>500.0 then speed#=500.0
endif
if mouseclick() = 2
inc speed#,-1000*elapsedtime#
if speed#<-500.0 then speed#=-500.0
endif
if mouseclick()=0
if speed#>0
inc speed#,-1000*elapsedtime#
if speed#<0.0 then speed#=0.0
else
inc speed#,1000*elapsedtime#
if speed#>0.0 then speed#=0.0
endif
endif
rotate camera maincam,xrot#+mousemovey()/6.0,camera angle y()+mousemovex()/6.0,0
move camera 0,speed#*elapsedtime#
sync
loop
end
function gaussian_function(x as float,z as float,centerx as float,centerz as float,spread as float,intensity as float)
xterm#=((x-centerx)/spread)^2
zterm#=((z-centerz)/spread)^2
height#=intensity*EXP(0-(xterm#+zterm#)) ` # signs added as well
endfunction height#
function makenorm(matno,matx,matz,sizex,sizez,spread,intensity)
rem make a matrix
make matrix matno,matx,matz,sizex,sizez
`position matrix matno, matx*matno,0,matz
hillno = 40
dim hill(hillno,3) `0 = cntx 1= cntz 2= sprd 3 = int
dim height#(hillno)
for h = 1 to hillno
ni = 0
hill(h,0) = rnd(sizex)
hill(h,1) = rnd(sizez)
hill(h,2) = rnd(spread-10)+10
hill(h,3) = rnd(intensity/3) + intensity/2
next h
cumulheight# = 0
rem make the gaussian hill
for x=0 to sizex `maximum matrix width
for z=0 to sizez `maximum matrix height
cumulheight# = 0
x# = x
z# = z
for hill = 1 to hillno
height#(hill) = gaussian_function(x#,z#,hill(hill,0),hill(hill,1),hill(hill,2),hill(hill,3))
cumulheight# = cumulheight# + height#(hill)
next hill
set matrix height matno,x,z,cumulheight#`height#(1) + height#(2) + height#(3) + height#(4) + height#(5) + height#(6) + height#(7) + height#(8) + height#(9) + height#(10)
next y
next x
update matrix matno
endfunction
function splitmatrix(mat,splitx,splity,oldsizex,oldsizey,oldnox,oldnoy) `split value is how many new smaller matrices you want
newsizex = oldsizex / splitx
newsizey = oldsizey / splity
newnox = newsizex / 12
newnoy = newsizey / 12
for x = 0 to oldnox
for y = 0 to oldnoy
oldheight#(x,y) = get matrix height(mat,x,y)
next y
next x
x = 0
y = 0
for m = 2 to splitx*splity+1
make matrix m, newsizex,newsizey,newnox,newnoy
position matrix m, x*newsizex,0,y*newsizey
mat(m,1) = matrix position x(m)
mat(m,2) = matrix position z(m)
mat(m,3) = newsizex
mat(m,4) = newsizey
for hx = 0 to newnox
for hy = 0 to newnoy
newheight# = oldheight#((x*newnox)+hx,(y*newnoy)+hy)
set matrix height m, hx,hy,newheight#
next hy
next hx
inc y
if y = splity
x = x + 1
y = 0
endif
update matrix m
next m
`12345^
`67890^
`12345^
`67890^
`12345^
`>>>>>
`setlodmatrices(2,5,5,mat(2,3),mat(2,4))
delete matrix 1
endfunction 1
function texturenorm(splitx,splity)
create bitmap 1, 400,400
set current bitmap 1
ink rgb(rnd(100),rnd(100)+100,rnd(100)),0
box 0,0,400,400
ink rgb(rnd(100)+100,rnd(100)+100,rnd(100)+100),0
for l = 1 to 100
line rnd(400),rnd(400),rnd(400),rnd(400)
next l
get image 1,0,0,400,400
set current bitmap 0
delete bitmap 1
paste image 1,0,0
ink rgb(255,255,255),0
for mat = 2 to splitx*splity+1
prepare matrix texture mat,1,1,1
`set matrix wireframe on mat
update matrix mat
next mat
endfunction
`_________________Memblock_______________________________________________________________
function memblock(nsx,nsy,splitx,splity)
dim matrixheight#(9,nsx,nsy)
for mem = 2 to splitx*splity+1
makematrix(mem,600,600,50,50)
texturematrix(mem,1,32,32)
for x = 0 to tilex(mem)
for z = 0 to tilez(mem)
matrixheight#(mem,x,z) = get matrix height(mem,x,z)
setmatrixheight(mem,x,z,matrixheight#(mem,x,z))
if matrixheight#(mem,x,z)>=3 and matrixheight#(mem,x,z)<6 then color=rgb(int(200-((matrixheight#(mem,x,z)-200)*1.50)),int(150+((matrixheight#(mem,x,z)-200)*1.00)),50)
if matrixheight#(mem,x,z)>=6 and matrixheight#(mem,x,z)<80 then color=rgb(int(50+((matrixheight#(mem,x,z)-3)*1.00)),int(250-((matrixheight#(mem,x,z)-3)*1.00)),int(50+((matrixheight#(mem,x,z)-3)*1.00)))
if matrixheight#(mem,x,z)>=80 then color=rgb(250,250,250)
if matrixheight#(mem,x,z)<3 then color=rgb(0,0,255)
setmatrixcolor(mem,x,z,color)
next z
next
normalizematrix(mem,0,0,tilex(1),tilez(1))
positionmatrix(mem,matrix position x(mem),matrix position y(mem),matrix position z(mem))
updatematrix(mem)
delete matrix mem
next mem
endfunction
function makematrix(mem,x#,z#,tilex,tilez)
tilex(mem)=tilex
tilez(mem)=tilez
tilesizex#(mem)=x#/tilex(mem)
tilesizez#(mem)=z#/tilez(mem)
polys=2*tilex*tilez
size=(polys*36*3)+12
make memblock mem,size
write memblock dword mem,0,338
write memblock dword mem,4,36
write memblock dword mem,8,polys*3
pos=12
for x=1 to tilex(mem)
for z=1 to tilez(mem)
writevectordata(mem,pos,(x-1.0)*tilesizex#(mem),0.000,(z-1.0)*tilesizez#(mem),0.000,1.000,0.000,rgb(255,255,255),0.000,1.000)
writevectordata(mem,pos+36,x*tilesizex#(mem),0.000,z*tilesizez#(mem),0.000,1.000,0.000,rgb(255,255,255),1.000,0.000)
writevectordata(mem,pos+72,x*tilesizex#(mem),0.000,(z-1.0)*tilesizez#(mem),0.000,1.000,0.000,rgb(255,255,255),1.000,1.000)
writevectordata(mem,pos+108,(x-1.0)*tilesizex#(mem),0.000,(z-1.0)*tilesizez#(mem),0.000,1.000,0.000,rgb(255,255,255),0.000,1.000)
writevectordata(mem,pos+144,(x-1.0)*tilesizex#(mem),0.000,z*tilesizez#(mem),0.000,1.000,0.000,rgb(255,255,255),0.000,0.000)
writevectordata(mem,pos+180,x*tilesizex#(mem),0.000,z*tilesizez#(mem),0.000,1.000,0.000,rgb(255,255,255),1.000,0.000)
pos=pos+216
next z
next x
object(mem)=mem+50`000
make mesh from memblock object(mem),mem
make object object(mem),object(mem),0
endfunction
function writevectordata(mem,pos,X# as float,Y# as float,Z# as float,NX# as float,NY# as float,NZ# as float,color as dword,TU# as float,TV# as float)
write memblock float mem,pos,X#
write memblock float mem,pos+4,Y#
write memblock float mem,pos+8,Z#
write memblock float mem,pos+12,NX#
write memblock float mem,pos+16,NY#
write memblock float mem,pos+20,NZ#
write memblock dword mem,pos+24,color
write memblock float mem,pos+28,TU#
write memblock float mem,pos+32,TV#
endfunction
function setmatrixheight(mem,x,z,y#)
if x-1>=0 and z-1>=0
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+40,y#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+184,y#
endif
if x-1>=0 and z<tilez(mem)
write memblock float mem,12+(216*(((x-1)*tilez(mem))+z))+76,y#
endif
if x<tilex(mem) and z-1>=0
write memblock float mem,12+(216*((x*tilez(mem))+(z-1)))+148,y#
endif
if x<tilex(mem) and z<tilez(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+4,y#
write memblock float mem,12+(216*((x*tilez(mem))+z))+112,y#
endif
endfunction
function setmatrixcolor(mem,x,z,color)
if x-1>=0 and z-1>=0
write memblock dword mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+60,color
write memblock dword mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+204,color
endif
if x-1>=0 and z<tilez(mem)
write memblock dword mem,12+(216*(((x-1)*tilez(mem))+z))+96,color
endif
if x<tilex(mem) and z-1>=0
write memblock dword mem,12+(216*((x*tilez(mem))+(z-1)))+168,color
endif
if x<tilex(mem) and z<tilez(mem)
write memblock dword mem,12+(216*((x*tilez(mem))+z))+24,color
write memblock dword mem,12+(216*((x*tilez(mem))+z))+132,color
endif
endfunction
function setmatrixnormal(mem,x,z,nx#,ny#,nz#)
if x-1>=0 and z-1>=0
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+48,nx#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+52,ny#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+56,nz#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+192,nx#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+196,ny#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+200,nz#
endif
if x-1>=0 and z<tilez(mem)
write memblock float mem,12+(216*(((x-1)*tilez(mem))+z))+84,nx#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+z))+88,ny#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+z))+92,nz#
endif
if x<tilex(mem) and z-1>=0
write memblock float mem,12+(216*((x*tilez(mem))+(z-1)))+156,nx#
write memblock float mem,12+(216*((x*tilez(mem))+(z-1)))+160,ny#
write memblock float mem,12+(216*((x*tilez(mem))+(z-1)))+164,nz#
endif
if x<tilex(mem) and z<tilez(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+12,nx#
write memblock float mem,12+(216*((x*tilez(mem))+z))+16,ny#
write memblock float mem,12+(216*((x*tilez(mem))+z))+20,nz#
write memblock float mem,12+(216*((x*tilez(mem))+z))+120,nx#
write memblock float mem,12+(216*((x*tilez(mem))+z))+124,ny#
write memblock float mem,12+(216*((x*tilez(mem))+z))+128,nz#
endif
endfunction
function getmatrixheight(mem,x,z)
if x-1>=0 and z-1>=0
height#=memblock float(mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+40)
else
if x<tilex(mem) and z<tilez(mem)
height#=memblock float(mem,12+(216*((x*tilez(mem))+z))+4)
else
height#=memblock float(mem,12+(216*(((x-1)*tilez(mem))+z))+76)
endif
endif
endfunction height#
function randomizematrix(mem,bx,bz,ex,ez,value#)
for x=bx to ex
for z=bz to ez
setmatrixheight(mem,x,z,(rnd(int(value#*100))/100.0)-(0.5*value#))
next z
next x
endfunction
function normalizematrix(mem,bx,bz,ex,ez)
if bx<=0 then bx=1
if bz<=0 then bz=1
if ex>=tilex(mem) then ex=tilex(mem)-1
if ez>=tilez(mem) then ez=tilez(mem)-1
rem Use matrix normals to make it smooth
for z=bz to ez
for x=bx to ex
rem Get matrix heights
h8#=getmatrixheight(mem,x,z-1)
h4#=getmatrixheight(mem,x-1,z)
h#=getmatrixheight(mem,x,z)
h2#=getmatrixheight(mem,x,z)
rem Calculate projected angle X using heights
x1#=(x-1)*25.0 : y1#=h#
x2#=(x+0)*25.0 : y2#=h4#
dx#=x2#-x1#
dy#=y2#-y1#
ax#=atanfull(dx#,dy#)
ax#=wrapvalue(90-ax#)
rem Calculate projected angle Z using heights
z1#=(z-1)*25.0 : y1#=h2#
z2#=(z+0)*25.0 : y2#=h8#
dz#=z2#-z1#
dy#=y2#-y1#
az#=atanfull(dz#,dy#)
az#=wrapvalue(90-az#)
rem Make normal from projected angle
nx#=sin(ax#)
ny#=cos(ax#)
nz#=sin(az#)
rem Setting matrix normal for smoothness
setmatrixnormal(1,x,z,nx#,ny#,nz#)
next x
next z
endfunction
function updatematrix(mem)
change mesh from memblock object(mem),mem
change mesh object(mem),0,object(mem)
texture object object(mem),texture(mem)
endfunction
function getgroundheight(mem,x#,z#)
if x#>=0 and z#>=0 and x#<tilex(mem)*tilesizex#(mem) and z#<tilez(mem)*tilesizez#(mem)
xt=int(x#/tilesizex#(mem))
zt=int(z#/tilesizez#(mem))
if (((xt+1)*tilesizex#(mem))-x#)+(z#-(zt*tilesizez#(mem)))<=tilesizex#(mem)
dx#=getmatrixheight(mem,xt+1,zt)-getmatrixheight(mem,xt,zt)
dz#=getmatrixheight(mem,xt+1,zt+1)-getmatrixheight(mem,xt+1,zt)
else
dx#=getmatrixheight(mem,xt+1,zt+1)-getmatrixheight(mem,xt,zt+1)
dz#=getmatrixheight(mem,xt,zt+1)-getmatrixheight(mem,xt,zt)
endif
height#=(((x#-(xt*tilesizex#(mem)))/tilesizex#(mem))*dx#)+(((z#-(zt*tilesizez#(mem)))/tilesizez#(mem))*dz#)+getmatrixheight(mem,xt,zt)
endif
endfunction height#
function preparematrixtexture(mem,image,xsplit,ysplit)
texture(mem)=image
xpart#(mem)=1.000/xsplit
ypart#(mem)=1.000/ysplit
for x=0 to tilex(mem)-1
for z=0 to tilez(mem)-1
setmatrixtile(mem,x,z,1,1)
next z
next x
endfunction
function setmatrixtile(mem,x,z,xtex,ytex)
write memblock float mem,12+(216*((x*tilez(mem))+z))+28,(xtex-1)*xpart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+32,ytex*ypart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+64,xtex*xpart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+68,(ytex-1)*ypart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+100,xtex*xpart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+104,ytex*ypart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+136,(xtex-1)*xpart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+140,ytex*ypart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+172,(xtex-1)*xpart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+176,(ytex-1)*ypart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+208,xtex*xpart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+212,(ytex-1)*ypart#(mem)
endfunction
function texturematrix(mem,image,xtile#,ztile#)
texture(mem)=image
texx#=xtile#/tilex(mem)
texz#=ztile#/tilez(mem)
for x=0 to tilex(mem)-1
for z=0 to tilez(mem)-1
z2=(tilez(mem)-z)-1
write memblock float mem,12+(216*((x*tilez(mem))+z2))+28,(x*texx#)
value#=((z+1)*texz#) : if value#=0.00 then value#=1.00
write memblock float mem,12+(216*((x*tilez(mem))+z2))+32,value#
value#=((x+1)*texx#) : if value#=0.00 then value#=1.00
write memblock float mem,12+(216*((x*tilez(mem))+z2))+64,value#
write memblock float mem,12+(216*((x*tilez(mem))+z2))+68,(z*texz#)
value#=((x+1)*texx#) : if value#=0.00 then value#=1.00
write memblock float mem,12+(216*((x*tilez(mem))+z2))+100,value#
value#=((z+1)*texz#) : if value#=0.00 then value#=1.00
write memblock float mem,12+(216*((x*tilez(mem))+z2))+104,value#
write memblock float mem,12+(216*((x*tilez(mem))+z2))+136,(x*texx#)
value#=((z+1)*texz#) : if value#=0.00 then value#=1.00
write memblock float mem,12+(216*((x*tilez(mem))+z2))+140,value#
write memblock float mem,12+(216*((x*tilez(mem))+z2))+172,(x*texx#)
write memblock float mem,12+(216*((x*tilez(mem))+z2))+176,(z*texz#)
value#=((x+1)*texx#) : if value#=0.00 then value#=1.00
write memblock float mem,12+(216*((x*tilez(mem))+z2))+208,value#
write memblock float mem,12+(216*((x*tilez(mem))+z2))+212,(z*texz#)
next z
next x
endfunction
function positionmatrix(mem,x#,y#,z#)
position object object(mem),x#,y#,z#
endfunction
function ghostmatrix(mem,ghost)
ghost object on object(mem),ghost
endfunction
function waves(mem,state)
if state = 1
for w = mem to mem + 1
makematrix(w,64*60,64*60,8,8)
texturematrix(w,2,1,1)
updatematrix(w)
positionmatrix(w,0,0,0)
ghostmatrix(w,w-1)
next w
`set object cull 50002,0
else
make object box mem, 3000,0,3000
color object mem,255
position object mem,1500,3,1500
ghost object on mem
endif
ink rgb(255,255,255),0
endfunction
`_________________________LOD____________________________________________________________
function setlodmatrices(mat,splitx,splity,newsizex,newsizey)
`start ratio = 12
newnox = newsizex / 12`ratio#
newnoy = newsizey / 12`ratio#
`find midpoints of matrices
ratio2 = 4
for mat = 2 to splitx*splity+1
midpoint(mat,1) = matrix position x(mat) + 0.5*newsizey
midpoint(mat,2) = matrix position z(mat) + 0.5*newsizey
dist# = sqrt(((midpoint(mat,1) - camera position x(0))*(midpoint(mat,1) - camera position x(0))) + ((midpoint(mat,2) - camera position z(0))*(midpoint(mat,2) - camera position z(0))))
`ratio1# = (1000/dist#) + 1
if dist# >= 500 and dist# < 1000 then ratio2 = 8
if dist# >= 1000 and dist# < 1500 then ratio2 = 16
if dist# >= 1500 then ratio2 = 32
`lodmatrix1(mat,splitx,splity,newsizex,newsizey,newnox,newnoy,ratio1#)
lodmatrix2(mat,splitx,splity,newsizex,newsizey,newnox,newnoy,ratio2)
next mat
`find which matrix camera is on
`for mat = 2 to splitx*splity+1
`if camera position x(0) > matrix position x(mat) and camera position x(0) < matrix position x(mat) + newsizex
`if camera position z(0) > matrix position z(mat) and camera position z(0) < matrix position z(mat) + newsizey
`position = mat
`endif
`endif
`next mat
`find dist between camera and midpoints of other matrices and set lod
`for mat = 2 to splitx*splity+1
`next mat
endfunction
function lodmatrix1(mat,splitx,splity,matsizex,matsizey,newnox,newnoy,ratio#)
matnox = matsizex / ratio#
matnoy = matsizey / ratio#
posx = matrix position x(mat)
posz = matrix position z(mat)
for x = 0 to newnox
for z = 0 to newnoy
lodheight#(mat,x,z) = get matrix height(mat,x,z)
next z
next x
delete matrix mat
make matrix mat,matsizex,matsizey,matnox,matnoy
`i need to average the heights across the different tiles in order to make this work
for x = 0 to matnox
for z = 0 to matnoz
set matrix height mat,x,z,lodheight#(mat,x,z)
next z
next x
position matrix mat, posx,0,posz
endfunction
function lodmatrix2(mat,splitx,splity,matsizex,matsizey,newnox,newnoy,ratio)
oldmatnox = matnox
oldmatnoy = matnoy
matnox = matsizex / ratio
matnoy = matsizey / ratio
posx = matrix position x(mat)
posz = matrix position z(mat)
if done = 0
rangex = newnox
rangey = newnoy
else if done = 1
rangex = matnox
rangey = matnoy
endif
endif
for x = 0 to rangex
for z = 0 to rangey
lodheight#(mat,x,z) = get matrix height(mat,x,z)
next z
next x
done = 1
delete matrix mat
make matrix mat,matsizex,matsizey,matnox,matnoy
difference = 12/ratio
for x = 0 to matnox step difference
for z = 0 to matnoz step difference
set matrix height mat,x,z,lodheight#(mat,x,z)
next z
next x
position matrix mat, posx,0,posz
endfunction
`____________________Move_____________________________________
movematrices:
`find which matrix camera is on
for mat = 2 to splitx*splity+1
size = object size z(mat+50)
if camera position x(0) > object position x(mat+50) and camera position x(0) < object position x(mat+50) + size
if camera position z(0) > object position z(mat+50) and camera position z(0) < object position z(mat+50) + size
position = mat
endif
endif
next mat
if position >= 2 and position <= 6 then col = 5
if position >= 7 and position <= 11 then col = 4
if position >= 12 and position <= 16 then col = 3
if position >= 17 and position <= 21 then col = 2
if position >= 22 and position <= 26 then col = 1
row = position - ((5-col)*splitx)-1
if col < midcol and col > midcol - 2 or col = midcol + 4 then state$ = "left"
if col > midcol and col < midcol + 2 or col = midcol - 4 then state$ = "right"
if row > midrow and row < midrow + 2 or row = midrow - 4 then state$ = "up"
if row < midrow and row > midrow - 2 or row = midrow + 4 then state$ = "down"
if state$ = "up"
for obj = 1 to splitx
move = findobj(midrow,midcol,-2,"r",obj)
position object move+50, object position x(move+50), object position y(move+50), object position z(move+50) + splitx*(size+1)
next obj
endif
if state$ = "down"
for obj = 1 to splitx
move = findobj(midrow,midcol,2,"r",obj)
position object move+50, object position x(move+50), object position y(move+50), object position z(move+50) - splitx*(size+1)
next obj
endif
if state$ = "left"
for obj = 1 to splitx
move = findobj(midrow,midcol,2,"c",obj)
position object move+50, object position x(move+50) + splitx*(size+1), object position y(move+50), object position z(move+50)
next obj
endif
if state$ = "right"
for obj = 1 to splitx
move = findobj(midrow,midcol,-2,"c",obj)
position object move+50, object position x(move+50) - splitx*(size+1), object position y(move+50), object position z(move+50)
next obj
endif
midcol = col
midrow = row
state$ = "set"
return
function findobj(midrow,midcol,offset,find$,no)
`row 1 = 2,7,12,17,22
`row 2 = 3,8,13,18,23
`row 3 = 4,9,14,19,24
`row 4 = 5,10,15,20,25
`row 5 = 6,11,16,21,26
`col 1 = 2 to 6
`col 2 = 7 to 11
`col 3 = 12 to 16
`col 4 = 17 to 21
`col 5 = 21 to 26
`row = position - ((col-1)*splitx)-1
if find$ = "r"
`find all obj in row = midrow -2
r = midrow + offset
if r <=0 then r = 5+r
if r >5 then r = r-5
position = ((no-1)*5) + r + 1
endif
if find$ = "c"
c = midcol + offset
if c<=0 then c = 5+c
if c > 5 then c = c-5
position = ((5-c)*5) + no + 1
endif
endfunction position
If anyone tries this, please say what fps you get, because i think its fairly pc intensive at the mo, i only get 33. =)
P.s at the start of the next challenge, im gonna post something in the forum to get some attention.