basically you need to know the x and z co-ordinates of the matrix and then adjust your cones once they reach them....
i.e.
say ur matrix is 300x300,10,10 and placed at 0,0,0
and ur cone is object 1, placed at 150,0,0 and pointing towards 150,0,300....
ur code should look like
move object 1,10
if object position x(1)<10
if rnd(1)=0 then rotate object 1,180 + rnd(20)
if rnd(1)=1 then rotate object 1,180 - rnd(20)
position object 1,10,0,object position z(1)
endif
and then the same for x>290
and then for the z values (which in this case will be the same)
that the sort of thing your looking for?
life's one big game