Anyone help me? I've tried something else, here it is. I need to finish this VERY SOON and have no idea how to.
Updated Code
sync rate 60
randomize timer()
Rem Title Screen
cls 0
load bitmap "images/Stranded_TitleScreen.jpg"
ink rgb(255,0,0),0 : set text font "arial" : set text size 14 : set text to bold : set text transparent
center text 320,420,"Developed by Shane Sullivan"
center text 320,434,"Copyright (c) 2012 Shane Sullivan"
wait key
Rem Declare Variables
MyTimer = 1500
sphereCount = 0
lastSphere = 10
MyScore = 0
global sphereCount
global lastSphere
global px#
global py#
global pz#
Rem Make/Load Objects
Rem Player
make object cube 99,15
Rem Textures
load image "images/sand_dunes.jpg",10
Rem 4 Corners of the Map
make object sphere 6, 100,100,100
make object sphere 7, 100,100,100
make object sphere 8, 100,100,100
make object sphere 9, 100,100,100
Rem Hide/Show 4 Corners of the Map
hide object 6
hide object 7
hide object 8
hide object 9
Rem Map Boundaries
make object box 2, 10,1300,1300
make object collision box 2, 0,0,0,10,1300,1300,1
make object box 3, 10,1300,1300
make object collision box 3, 0,0,0,10,1300,1300,1
make object box 4, 10,1300,1300
make object collision box 4, 0,0,0,10,1300,1300,1
make object box 5, 10,1300,1300
make object collision box 5, 0,0,0,10,1300,1300,1
if object collision (99,2)
endif
if object collision (99,3)
endif
if object collision (99,4)
endif
if object collision (99,5)
endif
Rem Food
rem make object cube 1,50
for x = 11 to 20
make object sphere x,50
next x
if object exist (x + 1) = 21
endif
Rem Color Objects
Rem 4 Corners of the Map
color object 6, rgb(255,0,0)
color object 7, rgb(0,255,0)
color object 8, rgb(0,0,255)
color object 9, rgb(122,122,0)
Rem Map boundaries
texture object 2, 10
texture object 3, 10
texture object 4, 10
texture object 5, 10
Rem Position/Rotate Objects
Rem 4 Corners of the Map
position object 6, 0,300,0
position object 7, 1300,300,0
position object 8, 0,300,1300
position object 9, 1300,300,1300
Rem Map Boundaries
position object 2, 650,300,0
yrotate object 2, 90
position object 3, 1300,300,650
position object 4, 0,300,650
position object 5, 650,300,1300
yrotate object 5, 90
Rem Car
Rem Terrain Generation
`Terrain scale
xscale#=5
yscale#=1
zscale#=5
`Height map size in pixels
is=255
smooth=10 `Sets the smoothness of the terrain (1=least smooth)
detail=100 `Sets the detail of the terrain (1=least detailed)
Rndmap(is,smooth,detail)
Maketextures(is)
Maketerrain(1,xscale#,yscale#,zscale#)
ox#=(get terrain x size(99)*xscale#)/2
oz#=(get terrain z size(99)*zscale#)/2
oy#=get terrain ground height(99,ox#,oz#)
position object 99,ox#,oy#+7,oz#
make camera 1
PlaceBottles()
repeat
gosub controlcamera
gosub controlobject
text 20, 20, "Spheres Gathered = "+str$(sphereCount)
until spacekey()
end
controlcamera:
`Little bit of code just to move the camera about
cx#=camera position x(1)
cz#=camera position z(1)
cy#=camera position y(1)
cang#=camera angle y(1)
cspeed#=curvevalue((upkey()-downkey()),cspeed#,15)
CAngleY# = WrapValue(AngleY#+(rightkey()-leftkey())*5)
cang#=CurveAngle(AngleY#,camera angle y (1),15)
cx#=newxvalue(cx#,cang#,speed#)
cz#=newzvalue(cz#,cang#,speed#)
cy#=get terrain ground height(1,cx#,cz#)
position camera 1, cx#,cy#,cz#
yrotate camera 1, cang#
return
controlobject:
`Little bit of code just to move the object about
`set camera to follow 650,1300,1250,-90,5,10,0,1
ox#=object position x(99)
oz#=object position z(99)
oy#=object position y(99)
oang#=object angle y(99)
ospeed#=curvevalue((upkey()-downkey()),ospeed#,15)
oAngleY# = WrapValue(oAngleY#+(rightkey()-leftkey())*5)
oang#=CurveAngle(oAngleY#,object angle y (99),15)
ox#=newxvalue(ox#,oang#,ospeed#)
oz#=newzvalue(oz#,oang#,ospeed#)
oy#=get terrain ground height(99,ox#,oz#)
position object 99, ox#,oy#+7,oz#
yrotate object 99, oang#
return
function Rndmap(is,smooth,detail)
dim col(is,is)
dim newcol(is,is)
`Quick random high level wash
for x=0 to is
for y=0 to is
col(x,y)=rnd(30)+200
next y
next x
`leaves the outer edges high but lower's the middle
for x=9 to is-9
for y=9 to is-9
col(x,y)=rnd(80)+80
next y
next x
`Adds in random boxes and circles of different heights
for d=1 to detail
col=rnd(80)+80
if rnd(1)=1
rad=rnd(20)+1
rx=rnd((is-rad*4)-8)+rad*2+4
ry=rnd((is-rad*4)-8)+rad*2+4
for r=0 to rad
for ang=1 to 360
col(int(rx+sin(ang)*r),int(ry+cos(ang)*r))=col
next ang
next r
else
xs=rnd(20)+1
ys=rnd(20)+1
rx=rnd((is-xs*4)-8)+xs*2+4
ry=rnd((is-ys*4)-8)+ys*2+4
for x=rx-xs to rx+xs
for y=ry-ys to ry+ys
col(x,y)=col
next y
next x
endif
next d
`gives final random wash
for x=0 to is
for y=0 to is
col(x,y)=col(x,y)+(rnd(40)-20)
if col(x,y)>255 then col(x,y)=255
next y
next x
`Smooths out the texture
for s=1 to smooth
for x=2 to is-2
for y=2 to is-2
tcol=0
av=0
for sx=-2 to 2
for sy=-2 to 2
inc av
inc tcol,col(x+sx,y+sy)
next sy
next sx
newcol(x,y)=tcol/av
next y
next x
if s<5
for x=3 to is-3
for y=3 to is-3
col(x,y)=newcol(x,y)
next y
next x
endif
next s
`Draws image
lock pixels
for x=0 to is
for y=0 to is
dot x,y,rgb(newcol(x,y),newcol(x,y),newcol(x,y))
next y
next x
unlock pixels
`Saves image
get image 5000,0,0,is,is
if file exist("heightmap.jpg") then delete file "heightmap.jpg"
save image "heightmap.jpg",5000
delete image 5000
cls 0
undim col(0)
`The code below is commented out purely as i'm using the data in this array later on
`to generate the textures. It would usually be left in.
`undim newcol(0)
endfunction
function Maketerrain(tn,xscale#,yscale#,zscale#)
make object terrain 1
set terrain heightmap tn ,"heightmap.jpg"
set terrain scale tn ,xscale#,yscale#,zscale#
set terrain split tn ,16
set terrain tiling tn ,16
set terrain light tn ,1,-1,0,1,1,1,0.5
set terrain texture tn ,1000,2000
build terrain tn
update terrain tn
endfunction
Function Maketextures(is)
`Set to 0 for grass, 1 for sand
map=1
`Makes a random terrain texture
lock pixels
for x=0 to is
for y=0 to is
col#=newcol(x,y)
if col#>200 then col#=150
inc col#,rnd(20)-20
if map=0
dot x,y,rgb(0,col#,0)
else
dot x,y,rgb(col#,int(col#/1.1),int(col#/2))
endif
next y
next x
unlock pixels
get image 1000,0,0,is,is
cls 0
`Makes a random detail map
lock pixels
for x=0 to 200
for y=0 to 200
col#=rnd(40)+100+map*30
dot x,y,rgb(col#,col#,col#)
next y
next x
unlock pixels
get image 2000,0,0,200,200,1
cls 0
endfunction
Rem Main Section
do
Rem Live Screen Display
print "Seconds Left: ";(MyTimer/60)+ 1 :
Rem Check Timer
if MyTimer = 0
for x = 1 to 20
if object exist(x) = 1 then delete object x
next x
gosub EndSection
if MyTimer > 0 then MyTimer = MyTimer - 1 :
endif
loop
Rem Food generation
function Placebottles()
for ob = 11 to 20
if object exist (ob + 99) = 0
make object sphere ob + 99,15
endif
x# = rnd(900) + 150 : z# = rnd(900) + 150
y# = get terrain ground height(1,x#,z#) + 7
position object ob + 99,x#,y#,z#
show object ob + 99
next i
endfunction
Rem Food Collection
if object collision (99,11)
delete object 11
endif
if object collision (99,12)
delete object 12
endif
if object collision (99,13)
delete object 13
endif
if object collision (99,14)
delete object 14
endif
if object collision (99,15)
delete object 15
endif
if object collision (99,16)
delete object 16
endif
if object collision (99,17)
delete object 17
endif
if object collision (99,18)
delete object 18
endif
if object collision (99,19)
delete object 19
endif
if object collision (99,20)
delete object 20
endif
Endsection:
- s4rg3