Hi, I'm glad you liked the demo
. I just tested your code, it actually works just as it should. The only thing is that the fruits are positioned WAY too far down, so you can't see them. The camera is at at least 3000 on the Y-axis, so try positioning your fruits at 4000 or 5000. If you want your fruits to sit on top of the terrain, make them after the MAKE MATRIX and other matrix commands and use the
GET GROUND HEIGHT command to position them right on top of the terrain. GET GROUND HEIGHT tells the height of the terrain at a given point. If you added this line right after you positioned them normally, they would sit on the terrain (don't forget it has to go anywhere AFTER the MATRIX commands, otherwise the terrain (a.k.a. matrix) won't exist.
Here is the command syntax:
GET GROUND HEIGHT(Matrix #, X Position, Z Position )
And here is the line of code you would have to add:
POSITION OBJECT t + NumberOfFruits, Object Position X(t + NumberOfFruits), GET GROUND HEIGHT(1,Object Position X(t + NumberOfFruits) , Object Position Z(t + NumberOfFruits)), Object Position Z(t+ NumberOfFruits)
EDIT: Here is the code with the above changes. You might want to change your X/Z positions a little bit though.
rem -=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
REM
REM Project: Snow Project
REM Created: 7/21/2007 8:10:07 AM
REM
REM ***** Main Source File *****
REM
rem -=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
rem ===================================================================================================
rem
rem CONTROLS
rem (Use the arrow keys to move around and the mouse to look around. Hold SPACE to hide the snow.
rem
rem ===================================================================================================
rem Start Demo
Sync On
Sync Rate 60
Autocam off
randomize timer()
set ambient light 40
set camera range 1,10000
disable escapekey
rem Make some fog
fog on
fog distance 4000
rem Set the color to a blueish color
color=rgb(200,200,255)
fog color Color
set ambient light 50
color ambient light Color
color light 0,color
rem Setup the snow
#Include "Include/Snow Functions.dba"
GOSUB SQ_SetupSnow
rem Load music
Load Music "Music Triumph.mp3",1
loop music 1
rem Set some variables:
rem set the intensity of the snowstorm. Try setting it to 5 for a weaker storm. Play around with it.
Storm_Intensity=20
rem Set the number of snow objects used. *The more snow objects you have the lower your FPS but the more snowflakes there will be
rem and the higher the quality of the effect.
NumOfSnowObjects=20
rem Set the image for the snow
SnowImage=2
rem set the size of each snow object. I set it to 10000 so each plain would cover the whole world, but smaller values could work.
SnowSize=10000
rem Set each snow object's texture scale. This decides how many times the snow texture is mapped to the snow object. Use it to change the size of each snowflake
rem (assuming the size of the snow object stays the same)
SnowScale=45
rem Set the camera to update the snow on
SnowCamera=0
rem Set how fast the snow will fall (0=default value based on strength)
SnowFallSpeed=0
rem Set the snow mode to 1 (can also be set to 2 for a different effect)
SnowMode=1
rem Set the size of our world.
WorldSize=10000
rem Set the camera stats (for movement)
CamAcl#=0.25
CamSpeed#=0
TurnSpeed#=0
BoundLimit=int(WorldSize/30.0)
rem Load Images
Load Image "Ice.bmp",1
Load Image "Snow.bmp",2
Load Image "Sky.bmp",3
Load Image "Gradient.bmp",4
rem Make our terrain
make matrix 1,WorldSize,WorldSize,60,60
prepare matrix texture 1,1,1,1
Randomize_Matrix(1,60,WorldSize/5,WorldSize/2)
set matrix height 1,30,30,Worldsize
Smooth_Matrix(1,60,4)
Normalize_Matrix(1,60)
rem Fruits
NumberOfFruits = 5000
FruitColor = 0
for t = 1 to NumberOfFruits
make object sphere t + NumberOfFruits ,50
color object t + NumberOfFruits , rgb(r,g,0)
position object t + NumberOfFruits ,Rnd(4000)-950,30,Rnd(4000)-950
POSITION OBJECT t + NumberOfFruits, Object Position X(t + NumberOfFruits), GET GROUND HEIGHT(1,Object Position X(t + NumberOfFruits) , Object Position Z(t + NumberOfFruits)), Object Position Z(t+ NumberOfFruits)
make object collision box t + NumberOfFruits ,-25,-25,-25,25,25,25,0
next t
rem Make the snow
SQ_MakeSnow(NumOfSnowObjects,SnowImage,SnowSize,SnowScale)
rem Make the sky
make object sphere 900,-10000
scale object 900,100,100,25
texture object 900,3
set object ambient 900,0
xrotate object 900,90
fix object pivot 900
rem Make the Bloom-type effect gradient on the screen
Make Object Plain 901,100,100
position object 901,0,25,50
lock object on 901
texture object 901,4
ghost object on 901
set object ambient 901,0
rem Position the camera
Position camera Camera,WorldSize/2,0,WorldSize/2
rem Start loop
do
rem Update Sky
scroll object texture 900,0.0001,0
position object 900,camera position x(),camera position y(),camera position z()
rem Print the FPS
ink rgb(255,0,0),0
set cursor 0,0
print "FPS: ",screen fps()
rem Update camera Speed
inc CamSpeed#,CamAcl#*(upkey()-downkey())
if CamSpeed#>10 then CamSpeed#=10
if CamSpeed#<-10 then CamSpeed#=-10
rem Allow camera rotation
rotate camera camera angle x()+mousemovey()/8,camera angle y()+mousemovex()/8,0
if camera angle x()>90 then xrotate camera 90
if camera angle x()<-90 then xrotate camera -90
rem Slow camera
if CamSpeed#<0 and downkey()=0 and upkey()=0 then inc CamSpeed#,CamAcl#
if CamSpeed#>0 and downkey()=0 and upkey()=0 then dec CamSpeed#,CamAcl#
rem Stop camera if slowing it will not work
if abs(CamSpeed#)<CamAcl# and downkey()=0 and upkey()=0 then CamSpeed#=0.0
rem Update strife speed
inc TurnSpeed#,CamAcl#*(rightkey()-leftkey())
if TurnSpeed#>10 then TurnSpeed#=10
if TurnSpeed#<-10 then TurnSpeed#=-10
rem Same as CamSpeed# stuff...
if TurnSpeed#<0 and rightkey()=0 and leftkey()=0 then inc TurnSpeed#,CamAcl#
if TurnSpeed#>0 and rightkey()=0 and leftkey()=0 then dec TurnSpeed#,CamAcl#
if abs(TurnSpeed#)<CamAcl# and rightkey()=0 and leftkey()=0 then TurnSpeed#=0.0
rem Update the camera for real
Position cAmera newxvalue(camera position x(Camera),camera angle y(camera),CamSpeed#),camera position y(Camera),newzvalue(camera position z(Camera),camera angle y(camera),CamSpeed#)
Position cAmera newxvalue(camera position x(Camera),camera angle y(camera)+90,TurnSpeed#),camera position y(Camera),newzvalue(camera position z(Camera),camera angle y(camera)+90,TurnSpeed#)
position camera camera position x(Camera),get ground height(1,camera position x(Camera),camera position z(Camera))+30,camera position z(Camera)
rem Keep the camera in bounds
if camera position x(Camera)>WorldSize-BoundLimit then position camera Camera,worldSize-BoundLimit,camera position y(Camera),camera position z(Camera)
if camera position x(Camera)<0+BoundLimit then position camera Camera,0+BoundLimit,camera position y(Camera),camera position z(Camera)
if camera position z(Camera)>WorldSize-BoundLimit then position camera Camera,Camera Position x(Camera),camera position y(Camera),WorldSize-BoundLimit
if camera position z(Camera)<0+BoundLimit then position camera Camera,Camera Position x(Camera),camera position y(Camera),0+BoundLimit
rem Show the snow when space is not held down, otherwise hide it.
if spacekey() then SQ_HideSnow() : else : SQ_Showsnow()
rem Call the UpdateSnow command
SQ_UpdateSnow(SnowCamera,Storm_Intensity,SnowFallSpeed,SnowMode)
rem Clear everything and quit with escape
if escapekey() then flush video memory : end
sync
loop
end
rem Smooth_Matrix function code CREATED BY ZERK
Function Smooth_Matrix(matrix as integer,tiles as integer,smoothing as integer)
`smooth the matrix
smoothfactor = smoothing `the amount of smoothness you want to apply
for s = 1 to smoothfactor
for hy=1 to tiles-1
for hx=1 to tiles-1
h# = (get matrix height(matrix,hx+1,hy) + get matrix height(matrix,hx,hy-1) + get matrix height(matrix,hx-1,hy) + get matrix height(matrix,hx,hy+1))/4
set matrix height matrix,hx,hy,h#
next hx
next hy
next s
update matrix matrix
endfunction
rem Normalize_Matrix function code CREATED BY VAN B
Function Normalize_MAtrix(matrix as integer,tiles as integer)
for z=1 to Tiles
for x=1 to Tiles
rem Get matrix heights
h8#=get matrix height(Matrix,x,z-1)
h4#=get matrix height (Matrix,x-1,z)
h#=get matrix height (Matrix,x-1,z-1)
h2#=get matrix height (Matrix,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
matnormx#=sin(ax#)
matnormy#=cos(ax#)
matnormz#=sin(az#)
set matrix normal MAtrix,x,z,matnormx#,matnormy#,matnormz#
next x
next z
update matrix matrix
endfunction
function Randomize_Matrix(Matrix as integer,Tiles as integer,MinHeight as float,MaxHeight as float)
for x = 0 to Tiles
for y = 0 to Tiles
SET MATRIX HEIGHT Matrix,x,y,MinHeight+Rnd(MaxHeight-MinHeight)
next y
next x
Update Matrix Matrix
endfunction
And please use code tags when you post large amounts of code. The code tags look like this: [ code] CODE GOES HERE [ /code] (without the spaces in [ code] and [ /code])
<-- Spell based team dueling game!