I forgot bout this thread, if anyone wants to make that sim work, then here's functions.dba:
print "#include this in your own program!"
end
`1
function set camera to follow(num,dist#,height#,smooth#,r)
x#=object position x(num)
y#=object position y(num)
z#=object position z(num)
a#=object angle y(num)
set camera to follow x#,y#,z#,a#,dist#,height#+y#,smooth#,1
if r=1
point camera x#,y#,z#
endif
endfunction
`2
function make object#(num,type,xs#,ys#,zs#,xp#,yp#,zp#,xr#,yr#,zr#,color)
autocam off
if type=1 then make object cube num,100
if type=2 then make object sphere num,100
if type=3 then make object cylinder num,100
if type=4 then make object cone num,100
if type=5 then make object plain num,100,100
scale object num,xs#,ys#,zs#
color object num,color
rotate object num,xr#,yr#,zr#
position object num,xp#,yp#,zp#
endfunction
`3
function x spin object(num,xr#)
spin object(num,xr#,0.0,0.0)
endfunction
`4
function y spin object(num,yr#)
spin object(num,0.0,yr#,0.0)
endfunction
`5
function z spin object(num,zr#)
spin object(num,0.0,0.0,zr#)
endfunction
`6
function spin object(num,xr#,yr#,zr#)
xr1#=object angle x(num)
yr1#=object angle y(num)
zr1#=object angle z(num)
xr1#=wrapvalue(xr1#+xr#)
yr1#=wrapvalue(yr1#+yr#)
zr1#=wrapvalue(zr1#+zr#)
rotate object num,xr1#,yr1#,zr1#
endfunction
`7
function texture object(num,string$)
load image string$,1
texture object num,1
delete image 1
endfunction
`8
function get distance(num1,num2)
x1#=object position x(num1)
y1#=object position y(num1)
z1#=object position z(num1)
x2#=object position x(num2)
y2#=object position y(num2)
z2#=object position z(num2)
dx#=abs(x1#-x2#)
dy#=abs(y1#-y2#)
dz#=abs(z1#-z2#)
dist#=sqrt((dx#*dx#)+(dy#*dy#)+(dz#*dz#))
endfunction dist#
`9
function get 2D distance(x1,y1,x2,y2)
dx#=abs(x1-x2)
dy#=abs(y1-y2)
dist#=sqrt((dx#*dx#)+(dy#*dy#))
endfunction dist#
`10
function round(number#,round_amount#)
number#=number#/round_amount#
number2#=number#
number#=int(number#)
number3#=abs(number#-number2#)
if number3#>=0.5 then inc number#
number#=number#*round_amount#
endfunction number#
`11
function control(num,forward_amount#,backward_amount#,spin_amount#)
if upkey()=1 then move object num,forward_amount#
if downkey()=1 then move object num,0-backward_amount#
if leftkey()=1 then y spin object(num,0-spin_amount#)
if rightkey()=1 then y spin object(num,spin_amount#)
endfunction
`12
function matrix(num,string$,random#)
if random#<>0.0 then randomize matrix num,random#
load bitmap string$,1
get image 1,0,0,256,256
delete bitmap 1
prepare matrix texture 1,1,2,2
endfunction
`13
function put object on matrix(matrix_num,object_num)
x1#=object position x(object_num)
y#=object size y(object_num)/2
z1#=object position z(object_num)
y1#=get ground height2(matrix_num,x1#,z1#)+y#
position object object_num,x1#,y1#,z1#
endfunction
`14
function tilt limb to ground(matnum,objnum,lmbnum)
a#=object angle y(objnum)
x#=object position x(objnum)
z#=object position z(objnum)
foot#=80
ta#=wrapvalue(a#-45)
frontleftx#=newxvalue(x#,ta#,foot#) : frontleftz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+45)
frontrightx#=newxvalue(x#,ta#,foot#) : frontrightz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+225)
backleftx#=newxvalue(x#,ta#,foot#) : backleftz#=newzvalue(z#,ta#,foot#)
ta#=wrapvalue(a#+135)
backrightx#=newxvalue(x#,ta#,foot#) : backrightz#=newzvalue(z#,ta#,foot#)
rem Calculate degree of tilting from corner heights
frontlefth#=get ground height2(matnum,(frontleftx#-mx#),(frontleftz#-mz#))
frontrighth#=get ground height2(matnum,(frontrightx#-mx#),(frontrightz#-mz#))
backlefth#=get ground height2(matnum,(backleftx#-mx#),(backleftz#-mz#))
backrighth#=get ground height2(matnum,(backrightx#-mx#),(backrightz#-mz#))
across#=((frontrighth#-frontlefth#)+(backrighth#-backlefth#))/2.0
length#=((backlefth#-frontlefth#)+(backrighth#-frontrighth#))/2.0
rotate limb objnum,lmbnum,wrapvalue(length#/4.0),0,wrapvalue(across#/4.0)
endfunction
`15
function point in box(x1,y1,bx1,by1,bx2,by2,type)
in=0
if type=2
bx1=bx1-half(bx2)
by1=by1-half(by2)
bx2=bx1+bx2
by2=by1+by2
endif
if x1>bx1 and x1<bx2 and y1>by1 and y1<by2 then in=1
endfunction in
`16
function point in circle(x1,y1,x2,y2,rad)
in=0
dx=abs(x1-x2)
dy=abs(y1-y2)
dist=get 2D distance2(dx,dy)
if dist<abs(rad) then in=1
endfunction in
`17
function get 2D distance2(dx,dy)
dist=sqrt(dx*dx+dy*dy)
endfunction dist
`18
function use keys to control(val#,type1,type2,s)
if type1=1 then dec val#,s
if type2=1 then inc val#,s
endfunction val#
`19
function average(val1,val2)
val=(val1+val2)/2
endfunction val
`20
function box(x1,y1,x2,y2,type,solid)
if type=2
x2=half(x2)
y2=half(y2)
x1=x1-x2
y1=y1-y2
x2=x1+(x2*2)
y2=y1+(y2*2)
endif
if solid=1
box x1,y1,x2,y2
else
line x2,y1,x2,y2
line x1,y2,x2,y2
line x1,y1,x1,y2
line x1,y1,x2,y1
endif
endfunction
`21
function half(a)
a=a/2
endfunction a
`22
function double(a)
a=a*2
endfunction
`23
function third(a)
a=a/3
endfunction a
`24
function triple(a)
a=a*a
endfunction a
`25
function negative(a)
a=abs(a)
a=0-a
endfunction a
`26
function positive(a)
a=abs(a)
endfunction a
`27
function negative#(a#)
a#=abs(a#)
a#=0-a#
endfunction a#
`28
function positive#(a#)
a#=abs(a#)
endfunction a#
`29
function friction(speed#,frict#)
frict#=positive#(frict#)
if speed#>0 then speed#=speed#-frict#
if speed#<0 then speed#=speed#+frict#
if speed#<frict# and speed#>negative#(frict#) then speed#=0
endfunction speed#
`30
function newxvalue2D(x#,a#,amount#)
x#=newzvalue(x#,a#,amount#)
endfunction
`31
function newyvalue2D(y#,a#,amount#)
y#=newxvalue(y#,a#,amount#)
endfunction
`32
function curve_value(d#,a#,step#)
if a#>d# then a#=a#-step#
if a#<d# then a#=a#+step#
if a#< positive#(step#)+d# and a#> negative#(step#)+d# then a#=d#
endfunction a#
`33
function rnd2(max,min)
if min>max
temp=min
min=max
max=temp
endif
a=rnd((max-min))+min
endfunction a
`34
function move mouse(xa,ya)
position mouse mousex()+xa,mousey()+ya
endfunction
`35
function start(sync_rate,hide_mouse,on,color)
cls
sync on
sync rate sync_rate
if on=1
backdrop on
color backdrop color
endif
if hide_mouse=1 then hide mouse
cls
endfunction
`36
function rnd color()
color=rgb(rnd(255),rnd(255),rnd(255))
endfunction color
`37
function orbitvalue(x1#,x2#,xspeed#,amount#,frictamount#)
dx#=x1#-x2#
xspeed#=xspeed#+(dx#*amount#)
xspeed#=friction(xspeed#,(xspeed#/(frictamount#*100)))
endfunction xspeed#
`38
function triangle(x1,y1,x2,y2,x3,y3)
line x1,y1,x2,y2
line x2,y2,x3,y3
line x3,y3,x1,y1
endfunction
`39
function polygon3(x#,y#,width,height,r)
x1#=(x#+(width*sin(r)))+(height*cos(r))
y1#=(y#+(width*cos(r)))-(height*sin(r))
x3#=(x#-(width*sin(r)))+(height*cos(r))
y3#=(y#-(width*cos(r)))-(height*sin(r))
x2#=(x#-(height*cos(r)))
y2#=(y#+(height*sin(r)))
line x1#,y1#,x2#,y2#
line x2#,y2#,x3#,y3#
line x3#,y3#,x1#,y1#
endfunction
`40
function polygon4(x#,y#,width,height,r)
x1#=(x#+(width*sin(r)))-(height*cos(r))
y1#=(y#+(width*cos(r)))+(height*sin(r))
x4#=(x#-(width*sin(r)))-(height*cos(r))
y4#=(y#-(width*cos(r)))+(height*sin(r))
x2#=(x#+(width*sin(r)))+(height*cos(r))
y2#=(y#+(width*cos(r)))-(height*sin(r))
x3#=(x#-(width*sin(r)))+(height*cos(r))
y3#=(y#-(width*cos(r)))-(height*sin(r))
line x1#,y1#,x2#,y2#
line x2#,y2#,x3#,y3#
line x3#,y3#,x4#,y4#
line x4#,y4#,x1#,y1#
endfunction
`41
function circle(x1,y1,x2,y2)
ellipse ((x1+x2)/2),((y1+y2)/2),x2-((x1+x2)/2),y2-((y1+y2)/2)
endfunction
`42
function make object(num,type,xs,ys,zs,xp,yp,zp,xr,yr,zr,color)
autocam off
if type=1 then make object cube num,100
if type=2 then make object sphere num,100
if type=3 then make object cylinder num,100
if type=4 then make object cone num,100
if type=5 then make object plain num,100,100
scale object num,xs,ys,zs
color object num,color
rotate object num,xr,yr,zr
position object num,xp,yp,zp
endfunction
`43
function control with acceleration(num,mfa#,mba#,facc#,bacc#,frict#,sa#,sacc#,sfrict#)
if sfrict#>1 then sfrict#=1
if upkey()=1 and move#<mfa# then move#=move#+facc#
if upkey()=0 and move#>0 then move#=move#-frict#
if downkey()=1 and move#>negative#(mba#) then move#=move#-facc#
if downkey()=0 and move#<0 then move#=move#+frict#
if move#>negative#(frict#) and move#<frict# then move#=0
move object num,move#
if leftkey()=1 and spin#>negative#(sa#) then spin#=spin#-sacc#
if leftkey()=0 and spin#<0 then spin#=spin#+sfrict#
if rightkey()=1 and spin#<positive#(sa#) then spin#=spin#+sacc#
if rightkey()=0 and spin#>0 then spin#=spin#-sfrict#
y spin object(num,spin#)
endfunction
`44
function control with car physics(num,mfa#,mba#,facc#,bacc#,frict#,sa#,sacc#,sfrict#)
if sfrict#>1 then sfrict#=1
if upkey()=1 and move#<mfa# then move#=move#+facc#
if upkey()=0 and move#>0 then move#=move#-frict#
if downkey()=1 and move#>negative#(mba#) then move#=move#-facc#
if downkey()=0 and move#<0 then move#=move#+frict#
if move#>negative#(frict#) and move#<frict# then move#=0
move object num,move#
if leftkey()=1 and spin#>negative#(sa#) then spin#=spin#-sacc#
if leftkey()=0 and spin#<0 then spin#=spin#+sfrict#
if rightkey()=1 and spin#<positive#(sa#) then spin#=spin#+sacc#
if rightkey()=0 and spin#>0 then spin#=spin#-sfrict#
y spin object(num,spin#*(move#/30))
endfunction
`45
function attach object to object(num2,num1,x1#,y1#,z1#)
x#=object position x(num1)
y#=object position y(num1)
z#=object position z(num1)
a#=object angle y(num1)
y2#=y#+y1#
x2#=newxvalue(x#,a#,x1#)
z2#=newzvalue(z#,a#,z1#)
position object num2,x2#,y2#,z2#
endfunction
`46
function gravity(num,amount#,ground#,ceiling#,speed#)
x#=object position x(num)
y#=object position y(num)
z#=object position z(num)
speed#=speed#+amount#
y#=y#-speed#
if y#<ground# then speed#=negative#(speed#)
if y#>ceiling# then speed#=positive#(speed#)
position object num,x#,y#,z#
endfunction speed#
`47
function object chase object(num1,num2,speed#)
x1#=object position x(num1)
y1#=object position y(num1)
z1#=object position z(num1)
x2#=object position x(num2)
y2#=object position y(num2)
z2#=object position z(num2)
x1#=curve_value(x2#,x1#,speed#)
y1#=curve_value(y2#,y1#,speed#)
z1#=curve_value(z2#,z1#,speed#)
position object num1,x1#,y1#,z1#
endfunction
`48
function object chase object2(num1,num2,speed#,XSPEED#,YSPEED#)
x1#=object position x(num1)
y1#=object position y(num1)
z1#=object position z(num1)
x2#=object position x(num2)
y2#=object position y(num2)
z2#=object position z(num2)
x1#=curve_value(x2#+XSPEED#,x1#,speed#)
y1#=curve_value(y2#+YSPEED#,y1#,speed#)
z1#=curve_value(z2#,z1#,speed#)
position object num1,x1#,y1#,z1#
endfunction
`49
function keep object in box(num,left,top,right,bottom,rad)
x#=object position x(num)
y#=object position y(num)
z#=object position z(num)
if x#< left+rad then x#=left+rad
if y#< bottom+rad then y#=bottom+rad
if y#> top-rad then y#=top-rad
if x#> right-rad then x#=right-rad
position object num,x#,y#,z#
endfunction
`50
function label(x,y,w,h,s$)
box(x,y,w,h,2,0)
center text x,y-10,s$
endfunction
`51
function button clicked(x,y,w,h)
in=0
if point in box(mousex(),mousey(),x,y,w,h,2)=1 and mouseclick()=1 then in=1
endfunction in
`52
function label2(color1,x,y,w,h,s$)
ink color1,0
box(x,y,w,h,2,0)
center text x,y-10,s$
endfunction
`53
function letter$(val)
i=0
inc i:if val=i then s$="Esc"
inc i:if val=i then s$="1"
inc i:if val=i then s$="2"
inc i:if val=i then s$="3"
inc i:if val=i then s$="4"
inc i:if val=i then s$="5"
inc i:if val=i then s$="6"
inc i:if val=i then s$="7"
inc i:if val=i then s$="8"
inc i:if val=i then s$="9"
inc i:if val=i then s$="0"
inc i:if val=i then s$="-"
inc i:if val=i then s$="+"
inc i:if val=i then s$="BackSpace"
inc i:if val=i then s$="Tab"
inc i:if val=i then s$="q"
inc i:if val=i then s$="w"
inc i:if val=i then s$="e"
inc i:if val=i then s$="r"
inc i:if val=i then s$="t"
inc i:if val=i then s$="y"
inc i:if val=i then s$="u"
inc i:if val=i then s$="i"
inc i:if val=i then s$="o"
inc i:if val=i then s$="p"
inc i:if val=i then s$="["
inc i:if val=i then s$="]"
inc i:if val=i then s$="Enter"
inc i:if val=i then s$="Left Control"
inc i:if val=i then s$="a"
inc i:if val=i then s$="s"
inc i:if val=i then s$="d"
inc i:if val=i then s$="f"
inc i:if val=i then s$="g"
inc i:if val=i then s$="h"
inc i:if val=i then s$="j"
inc i:if val=i then s$="k"
inc i:if val=i then s$="l"
inc i:if val=i then s$=";"
inc i:if val=i then s$="'"
inc i:if val=i then s$="`"
inc i:if val=i then s$="Left Shift"
inc i:if val=i then s$="\"
inc i:if val=i then s$="z"
inc i:if val=i then s$="x"
inc i:if val=i then s$="c"
inc i:if val=i then s$="v"
inc i:if val=i then s$="b"
inc i:if val=i then s$="n"
inc i:if val=i then s$="m"
inc i:if val=i then s$=","
inc i:if val=i then s$="."
inc i:if val=i then s$="/"
inc i:if val=i then s$="Right Shift"
inc i:if val=i then s$="numpad*"
inc i:if val=i then s$="Left Alt"
inc i:if val=i then s$="Space Bar"
inc i:if val=i then s$="Caps Lock"
inc i:if val=i then s$="F1"
inc i:if val=i then s$="F2"
inc i:if val=i then s$="F3"
inc i:if val=i then s$="F4"
inc i:if val=i then s$="F5"
inc i:if val=i then s$="F6"
inc i:if val=i then s$="F7"
inc i:if val=i then s$="F8"
inc i:if val=i then s$="F9"
inc i:if val=i then s$="F10"
inc i:if val=i then s$="F11"
inc i:if val=i then s$="F12"
inc i:if val=i then s$="numpad7"
inc i:if val=i then s$="numpad8"
inc i:if val=i then s$="numpad9"
inc i:if val=i then s$="numpad-"
inc i:if val=i then s$="numpad4"
inc i:if val=i then s$="numpad5"
inc i:if val=i then s$="numpad6"
inc i:if val=i then s$="numpad+"
inc i:if val=i then s$="numpad1"
inc i:if val=i then s$="numpad2"
inc i:if val=i then s$="numpad3"
inc i:if val=i then s$="numpad0"
inc i:if val=i then s$="numpad."
inc i,(156-83):if val=i then s$="numpadEnter"
inc i:if val=i then s$="Right Control"
inc i,(181-157):if val=i then s$="numpad/"
inc i,2
inc i:if val=i then s$="Right Alt"
inc i,(199-184):if val=i then s$="Home"
inc i:if val=i then s$="Up Arrow"
inc i:if val=i then s$="Page Up"
inc i:if val=i then s$=""
inc i:if val=i then s$="Left Arrow"
inc i:if val=i then s$=""
inc i:if val=i then s$="Right Arrow"
inc i,2:if val=i then s$="End"
inc i:if val=i then s$="Down Arrow"
inc i:if val=i then s$="Page Down"
inc i:if val=i then s$="Insert"
inc i:if val=i then s$="Delete"
inc i,8:if val=i then s$="Left Windows"
inc i:if val=i then s$="Right Windows"
inc i:if val=i then s$="Special"
endfunction s$
`54
function key(s$)
val=0
val=keystate(value(s$))
endfunction val
`55
function value(s$)
i=0
inc i:if s$="Esc" then val=i
inc i:if s$="1" then val=i
inc i:if s$="2" then val=i
inc i:if s$="3" then val=i
inc i:if s$="4" then val=i
inc i:if s$="5" then val=i
inc i:if s$="6" then val=i
inc i:if s$="7" then val=i
inc i:if s$="8" then val=i
inc i:if s$="9" then val=i
inc i:if s$="0" then val=i
inc i:if s$="-" then val=i
inc i:if s$="+" then val=i
inc i:if s$="Backspace" then val=i
inc i:if s$="Tab" then val=i
inc i:if s$="q" then val=i
inc i:if s$="w" then val=i
inc i:if s$="e" then val=i
inc i:if s$="r" then val=i
inc i:if s$="t" then val=i
inc i:if s$="y" then val=i
inc i:if s$="u" then val=i
inc i:if s$="i" then val=i
inc i:if s$="o" then val=i
inc i:if s$="p" then val=i
inc i:if s$="[" then val=i
inc i:if s$="]" then val=i
inc i:if s$="Enter" then val=i
inc i:if s$="Left Control" then val=i
inc i:if s$="a" then val=i
inc i:if s$="s" then val=i
inc i:if s$="d" then val=i
inc i:if s$="f" then val=i
inc i:if s$="g" then val=i
inc i:if s$="h" then val=i
inc i:if s$="j" then val=i
inc i:if s$="k" then val=i
inc i:if s$="l" then val=i
inc i:if s$=";" then val=i
inc i:if s$="'" then val=i
inc i:if s$="`" then val=i
inc i:if s$="Left Shift" then val=i
inc i:if s$="\" then val=i
inc i:if s$="z" then val=i
inc i:if s$="x" then val=i
inc i:if s$="c" then val=i
inc i:if s$="v" then val=i
inc i:if s$="b" then val=i
inc i:if s$="n" then val=i
inc i:if s$="m" then val=i
inc i:if s$="," then val=i
inc i:if s$="." then val=i
inc i:if s$="/" then val=i
inc i:if s$="Right Shift" then val=i
inc i:if s$="numpad*" then val=i
inc i:if s$="Left Alt" then val=i
inc i:if s$="Space Bar" then val=i
inc i:if s$="Caps Lock" then val=i
inc i:if s$="F1" then val=i
inc i:if s$="F2" then val=i
inc i:if s$="F3" then val=i
inc i:if s$="F4" then val=i
inc i:if s$="F5" then val=i
inc i:if s$="F6" then val=i
inc i:if s$="F7" then val=i
inc i:if s$="F8" then val=i
inc i:if s$="F9" then val=i
inc i:if s$="F10" then val=i
inc i:if s$="F11" then val=i
inc i:if s$="F12" then val=i
inc i:if s$="numpad7" then val=i
inc i:if s$="numpad8" then val=i
inc i:if s$="numpad9" then val=i
inc i:if s$="numpad-" then val=i
inc i:if s$="numpad4" then val=i
inc i:if s$="numpad5" then val=i
inc i:if s$="numpad6" then val=i
inc i:if s$="numpad+" then val=i
inc i:if s$="numpad1" then val=i
inc i:if s$="numpad2" then val=i
inc i:if s$="numpad3" then val=i
inc i:if s$="numpad0" then val=i
inc i:if s$="numpad." then val=i
inc i,(156-83):if s$="numpadEnter" then val=i
inc i:if s$="Right Control" then val=i
inc i,(181-157):if s$="numpad/" then val=i
inc i,2
inc i:if s$="Right Alt" then val=i
inc i,(199-184):if s$="Home" then val=i
inc i:if s$="Up Arrow" then val=i
inc i:if s$="Page Up" then val=i
inc i,2:if s$="Left Arrow" then val=i
inc i,2:if s$="Right Arrow" then val=i
inc i,2:if s$="End" then val=i
inc i:if s$="Down Arrow" then val=i
inc i:if s$="Page Down" then val=i
inc i:if s$="Insert" then val=i
inc i:if s$="Delete" then val=i
inc i,8:if s$="Left Windows" then val=i
inc i:if s$="Right Windows" then val=i
inc i:if s$="Special" then val=i
endfunction val
`56
function object chase object3(num1,num2,speed#,XSPEED#,YSPEED#,hard)
x1#=object position x(num1)
y1#=object position y(num1)
z1#=object position z(num1)
x2#=object position x(num2)
y2#=object position y(num2)
z2#=object position z(num2)
if (x1#>x2#+hard) or (x1#<x2#-hard) then x1#=curve_value(x2#+XSPEED#,x1#,speed#)
if (y1#>y2#+hard) or (y1#<y2#-hard) then y1#=curve_value(y2#+YSPEED#,y1#,speed#)
z1#=curve_value(z2#,z1#,speed#)
position object num1,x1#,y1#,z1#
endfunction
`57
function point screen x(x#,y#,z#)
make object cube 333,0
position object 333,x#,y#,z#
val=object screen x(333)
delete object 333
endfunction val
`58
function point screen y(x#,y#,z#)
make object cube 333,0
position object 333,x#,y#,z#
val=object screen y(333)
delete object 333
endfunction val
`59
function camera_object dist(num)
x#=object position x(num)
y#=object position y(num)
z#=object position z(num)
cx#=camera position x()
cy#=camera position y()
cz#=camera position z()
dx#=abs(x#-cx#)
dy#=abs(y#-cy#)
dz#=abs(z#-cz#)
dist#=sqrt((dx#*dx#)+(dy#*dy#)+(dz#*dz#))
endfunction dist#
`60
function color matrix(n,color)
create bitmap 1,10,10
box 2,2,8,8
old_color=point(5,5)
cls
ink color,0
box 2,2,8,8
get image 1,4,4,6,6
prepare matrix texture n,1,1,1
delete bitmap 1
cls
ink old_color,0
update matrix n
endfunction
`61
function xrotate limb(num,n,xr#)
xr1#=limb angle x(num,n)
yr1#=limb angle y(num,n)
zr1#=limb angle z(num,n)
rotate limb num,n,wrapvalue(xr#),yr1#,zr1#
endfunction
`62
function yrotate limb(num,n,yr#)
xr1#=limb angle x(num,n)
yr1#=limb angle y(num,n)
zr1#=limb angle z(num,n)
rotate limb num,n,xr1#,wrapvalue(yr#),zr1#
endfunction
`63
function zrotate limb(num,n,zr#)
xr1#=limb angle x(num,n)
yr1#=limb angle y(num,n)
zr1#=limb angle z(num,n)
rotate limb num,n,xr1#,yr1#,wrapvalue(zr#)
endfunction
`64
function move object2(num,amount)
x#=object position x(num)
y#=object position y(num)
z#=object position z(num)
x#=newxvalue(x#,object angle y(num),amount*cos(limb angle x(num,1)))
y#=newyvalue(y#,0-limb angle x(num,1),amount)
z#=newzvalue(z#,object angle y(num),amount*cos(limb angle x(num,1)))
position object num,x#,y#,z#
endfunction
`65
function normalize(n,s)
For z=1 To s
For x=1 To s
h8#=Get Matrix Height(n,x,z-1)
h4#=Get Matrix Height(n,x-1,z)
h#=Get Matrix Height(n,x,z)
h2#=Get Matrix Height(n,x,z)
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#)
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#)
nx#=Sin(ax#): ny#=Cos(ax#): nz#=Sin(az#)
Set Matrix Normal n,x,z,nx#,ny#,nz#
Next x
Next z
update matrix n
endfunction
`66
function keep object above matrix(mnum,onum,height)
y#=object position y(onum)
x#=object position x(onum)
z#=object position z(onum)
if y#<get ground height2(mnum,x#,z#)+height then position object onum,x#,get ground height2(mnum,x#,z#)+height,z#
endfunction
`67
function get ground height2(num,x#,z#)
endfunction get ground height(num,x#-matrix position x(num),z#-matrix position z(num))
`68
function xposition mouse(pos)
position mouse pos,mousey()
endfunction
`69
function yposition mouse(pos)
position mouse mousex(),pos
endfunction
`70
function get height above ground(num,mnum)
h#=object position y(num)-get ground height3(mnum,num)
endfunction h#
`71
function get ground height3(mnum,num)
endfunction get ground height2(mnum,object position x(num),object position z(num))
`72
function line(x#,y#,rot#,rad#)
line x#,y#,x#+rad#*cos(rot#),y#+rad#*sin(rot#)
endfunction
`73
function get angle average(ang1,ang2)
ang1=wrapvalue(ang1)
ang2=wrapvalue(ang2)
ang3=(ang1+ang2)/2
ang3=ang1+ang2
if abs(ang1-ang2)>180 then ang3=ang3+180
endfunction ang3
`74
function get angle average#(ang1#,ang2#)
ang1#=wrapvalue(ang1#)
ang2#=wrapvalue(ang2#)
ang3#=(ang1#+ang2#)/2
if abs(ang1#-ang2#)>180 then ang3#=ang3#+180
endfunction ang3#
`75
function put camera on matrix(num,height#)
x#=camera position x()
z#=camera position z()
y#=get ground height2(num,x#,z#)
position camera x#,y#+height#,z#
endfunction
`76
function add limb#(objnum,lmbnum,type,x#,y#,z#,color)
n=find free object()
if type=1 then make object cube n,100
if type=2 then make object sphere n,100
if type=3 then make object cylinder n,100
if type=4 then make object cone n,100
if type=5 then make object plain n,100,100
m=find free mesh()
make mesh from object m,n
delete object n
add limb objnum,lmbnum,m
color limb objnum,lmbnum,color
scale limb objnum,lmbnum,x#,y#,z#
endfunction
`77
function find free object()
for i=1 to 600000
if object exist(i)=0 then n=i;goto endf
next i
endf:
endfunction n
`78
function find free mesh()
for i=1 to 600000
if mesh exist(i)=0 then n=i;goto endf
next i
endf:
endfunction n
`79
function make object2#(num,xp#,yp#,zp#)
autocam off
make object cube num,0
position object num,xp#,yp#,zp#
endfunction
www.CyberLuke.com