TGC Codebase Backup



Make_Hill by ReD_eYe

7th Sep 2003 15:16
Summary

A program to show how to use a make_hill function i have made



Description

see short



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem Make_hill function
rem By ReD_eYe

sync on
sync rate 50


make matrix 1,1000,1000,100,100


rem h=height
rem s=smoothing effect
rem r=radius(in tiles)
rem matnum=matrix number
rem x/z tile coordinates
h=200
s=30
r=10
matnum=1
x=50
z=50

make_hill(matnum,x,z,r,h,s)

do

control camera using arrowkeys 0,10,2
position camera camera position x(),100,camera position z()
sync
loop

function make_hill(matnum,xpos,zpos,r,h,s)

for x=xpos-r to xpos+r
for z=zpos-r to zpos+r
if x>0 and z>0
set matrix height matnum,x,z,h
endif
next z
next x

for t=1 to s
for x=xpos-r to xpos+r
for z=zpos-r to zpos+r
if x>0 and z>0
a=get matrix height(matnum,x-1,z+1)
b=get matrix height(matnum,x,z+1)
c=get matrix height(matnum,x+1,z+1)
d=get matrix height(matnum,x+1,z)
e=get matrix height(matnum,x+1,z-1)
f=get matrix height(matnum,x,z-1)
g=get matrix height(matnum,x-1,z-1)
h=get matrix height(matnum,x-1,z)
total=a+b+c+d+e+f+g+h
av#=total/8
set matrix height matnum,x,z,av#
endif

next z
next x
next t

update matrix matnum
endfunction