Sorry if this is covering old ground but I cant find an answer to this problem.
In a bit of code I am currently playing with an empty line generates an error.
Rem Project: driver
Rem Created: 24/01/03 17:25:42
AUTOCAM OFF
Rem ***** Main Source File *****
GOSUB setupvariables
GOSUB initalise
GOSUB physics
DO
GOSUB collisions
GOSUB physics
IF SPACEKEY()=1 THEN GOSUB initalise
LOOP
physics:
REM handles addition of velocities etc.
FOR L=1 TO objectnumber
object(L).position.x=object(L).position.x+object(L).velocity.x
object(L).position.y=object(L).position.y+object(L).velocity.y
object(L).position.z=object(L).position.z+object(L).velocity.z
POSITION OBJECT L, object(L).position.x, object(L).position.y, object(L).position.z
NEXT L
RETURN
collisions:
REM handles all collisions and reverses velocities
col=OBJECT COLLISION(1,2)
IF col0
`SUSPEND FOR KEY
rem calculate unit vector from 1->2
x_diff#=object(2).position.x-object(1).position.x
z_diff#=object(2).position.z-object(1).position.z
n_ang#=ATANFULL(x_diff#, y_diff#)
m(1).x=SIN(n_ang#)
m(1).z=COS(n_ang#)
e#=1 : rem e is degree of elasticity of impact (1=elastic)
rem calulate x velocities
v1i#=object(1).velocity.x
v2i#=object(2).velocity.x
n#=m(1).x
object(1).velocity.x=vf1(v1i#, v2i#, object(1).mass, object(2).mass, e#, n#)
object(2).velocity.x=vf2(v1i#, v2i#, object(1).mass, object(2).mass, e#, n#)
rem calulate z velocities
v1i#=object(1).velocity.z
v2i#=object(2).velocity.z
n#=m(1).z
object(1).velocity.z=vf1(v1i#, v2i#, object(1).mass, object(2).mass, e#, n#)
object(2).velocity.z=vf2(v1i#, v2i#, object(1).mass, object(2).mass, e#, n#)
ENDIF
RETURN
FUNCTION vf1(v1i#,v2i#,m1,m2,e#,n#)
REM calculates 1 axis of collision for object 1
rem v1i,v2i = initial speeds, m1,m2 = masses, e= elasticity, n=axis contribution to normal unit vector
c#=n#*(v1i#-v2i#)
vf1#=v1i#+(((m2*c#)/(m1+m2))*((1+e#)*n#))
RETURN vf1#
FUNCTION vf2(v1i#,v2i#,m1,m2,e#,n#)
REM calculates 1 axis of collision for object 2
rem v1i,v2i = initial speeds, m1,m2 = masses, e= elasticity, n=axis contribution to normal unit vector
c#=n#*(v1i#-v2i#)
vf2#=v2i#+(((m1*c#)/(m1+m2))*((1+e#)*n#))
RETURN vf2#
setupvariables:
TYPE vector
x AS FLOAT
y AS FLOAT
z AS FLOAT
ENDTYPE
TYPE obj
position AS vector
velocity AS vector
acceleration AS vector
rot AS vector
drag AS FLOAT
friction AS FLOAT
mass AS INTEGER
ENDTYPE
objectnumber=2
DIM object(objectnumber) AS obj
DIM m(1) AS vector :rem used to calculate a 1 unit vector for various reasons
RETURN
initalise:
RESTART=0
object(1).position.x=-500
object(1).position.z=-500
object(1).rot.y=45
object(1).velocity.x=1
object(1).velocity.z=1
object(2).position.x=0
object(2).position.z=0
object(2).velocity.x=0
object(2).velocity.z=0
object(2).rot.y=0
object(1).mass=1
object(2).mass=1
IF OBJECT EXIST(1)=0
MAKE OBJECT SPHERE 1,25
COLOR OBJECT 1,RGB(255,0,0)
MAKE OBJECT SPHERE 2,25
COLOR OBJECT 2,RGB(0,255,0)
ENDIF
POSITION CAMERA 0,500,0
POINT CAMERA 0,0,0
RETURN
FUNCTION hyp(x#,y#)
h#=SQRT((x#*x#)+(y#*y#))
ENDFUNCTION h#
Now there may be other problems with this as I cant run it to find any other bugs but I get "#100035: typ definition obj could not be understood at line 118."
Now I understand how to set up type/endtype but line 118 is the empty line after the endtype command.
I am running with patch 3. Dx8.1b (I think b, not 9 anyway)
Any suggestions how an empty line can generate an error?