I started to write a Tempest-like game with DBC v1.13 (well, now it has no interaction, it only displays the levels). The problem is that the levels (for which I use the Asin or Acos functions) are all screwed up! Or better,
half of each level is screwed up, and
which half depends from the function I use! Here I'll show you the snippet that actually displays the levels. Note that
1) the coordinates for each point in the level are stored in two 2-dimensional arrays: LEVELX(16,16) and LEVELY(16,16), and writing for example "LEVELX(1,4)" refers to the X coordinate of the 4th point in the 1st level
2) every object is a 10*0.1*10 box, which pivot point corresponds to its bottom-left vertex
LEVEL=1
For I=1 To 16
Load Object "box.x",I
Position Object I,LEVELX(LEVEL,I),LEVELY(LEVEL,I),0
Color Object I,Rgb(0,80,173)
Next I
For I=1 To 15
AC#=LEVELX(LEVEL,I+1)-LEVELX(LEVEL,I)
BC#=LEVELY(LEVEL,I+1)-LEVELY(LEVEL,I)
DIST#=Sqrt(AC#^2+BC#^2)
Scale Object I,DIST#*10,500,10000
ANGLE#=Acos(AC#/DIST#)
Rotate Object I,0.0,0.0,ANGLE#
Next I
AC#=LEVELX(LEVEL,16)-LEVELX(LEVEL,1)
BC#=LEVELY(LEVEL,16)-LEVELY(LEVEL,1)
DIST#=Sqrt(AC#^2+BC#^2)
Scale Object 16,DIST#*10,500,10000
ANGLE#=Acos(AC#/DIST#)
Rotate Object 16,0.0,0.0,ANGLE#
In theory, this level should be a cylinder, but here's how it is distorted:
http://devilmaster.supereva.it/tempest1.jpg
If I change the code to use the Asin function, like in the following snippet...
LEVEL=1
For I=1 To 16
Load Object "box.x",I
Position Object I,LEVELX(LEVEL,I),LEVELY(LEVEL,I),0
Color Object I,Rgb(0,80,173)
Next I
For I=1 To 15
AC#=LEVELX(LEVEL,I+1)-LEVELX(LEVEL,I)
BC#=LEVELY(LEVEL,I+1)-LEVELY(LEVEL,I)
DIST#=Sqrt(AC#^2+BC#^2)
Scale Object I,DIST#*10,500,10000
ANGLE#=Asin(BC#/DIST#)
If ANGLE#>=360 Then ANGLE#=ANGLE#-360
If ANGLE#<=0 Then ANGLE#=ANGLE#+360
Rotate Object I,0.0,0.0,ANGLE#
Next I
AC#=LEVELX(LEVEL,16)-LEVELX(LEVEL,1)
BC#=LEVELY(LEVEL,16)-LEVELY(LEVEL,1)
DIST#=Sqrt(AC#^2+BC#^2)
Scale Object 16,DIST#*10,500,10000
ANGLE#=Asin(BC#/DIST#)
If ANGLE#>=360 Then ANGLE#=ANGLE#-360
If ANGLE#<=0 Then ANGLE#=ANGLE#+360
Rotate Object 16,0.0,0.0,ANGLE#
...the opposite side is distorted, and this is the result:
http://devilmaster.supereva.it/tempest2.jpg
What am I doing wrong?