sync on;sync rate 60
firstload()
do
controls()
`text 0,20,"built terrain"
`text 0,40,"Save terrain" + str$(save)
sync
loop
function firstload()
global mousex# as float
global mousey# as float
global save
global land as integer = 5
global image1 as integer = 1
global image2 as integer = 2
global image3 as integer = 3
global image4 as integer = 4
global oldtimer
global change as integer = 255
load image "images/draw4.png",image1,1
sprite 1,50,50,image1
SET SPRITE image1,0,1
load image "images/bitmap1.png",image2
paste image 2,0,0
SET BITMAP FORMAT 32
set current bitmap 0
endfunction 0
function controls()
mousex#=mousex#+(mousemovey()/0.5)
mousey#=mousey#+(mousemovex()/0.5)
rotate camera wrapvalue(mousex#),wrapvalue(mousey#),0
if upkey()=1 then move camera 0,1
if downkey()=1 then move camera 0,-1
if mouseclick()=1
PASTE SPRITE image1, mousex()-32, mousey()-32
if timer() => oldtimer + 100
change = change - 1
SET SPRITE DIFFUSE 1,change, change, change
oldtimer = timer()
endif
else
if mouseclick()=0
change = 255
SET SPRITE DIFFUSE 1,change, change, change
endif
endif
if keystate(32)=1 and hd = 0
hd = 1
for i = 1 to 2
if image exist(i)=1 then delete image i
next i
secondload()
else
if keystate(50)=0
hd = 0
endif
endif
if mouseclick()=2
get image 3,0,0,screen width(),screen height()
save image "image.png",image3
endif
endfunction 0
function secondload()
load image "image.png",image3
load image "images/ground0.jpg",image4
make object terrain land
set terrain heightmap land,"image.png"
set terrain scale land,6,1.2,6
set terrain split land,16
set terrain texture land,image4,2
set terrain tiling land,4
build terrain land
endfunction 0