|
|
Hi(gh)!
And I thought I got it right... forget about it! While with speed=0.1
and starting angle=60 degrees all went fine, with speed=0.25 and
starting angle=340 degrees, at frame 219 the script starts to behave
bizarrely. As you can see in the attached video clip, the ball bounces
off a non-existing "horizontal" wall and then moves through the eastern
wall...
This is the collision detecting routine:
#declare rows=0; // check for collision with any stone
#while (rows < LevelLength)
#declare cols=0;
#while (cols < LevelWidth)
// #warning concat("row: ", str(rows, 1, 0), ", col: ", str (cols,
1, 0))
#if (layer2_array[rows][cols] = 1 | layer3_array[rows][cols] >= 20)
#declare xmin=cols-0.35;
#declare xmax=cols+1+0.35;
#declare zmin=rows-0.35;
#declare zmax=rows+1+0.35;
// horizontal obstacles
#if (ballpos_next.x >= xmin & ballpos_next.x <= xmax &
ballpos_next.z >= zmin & ballpos_next.z <= zmax & (ballpos.z < zmin |
ballpos.z > zmax))
#declare dir = 180-dir;
#declare hit=1;
#break
#end
// vertical obstacles
#if (ballpos_next.x >= xmin & ballpos_next.x <= xmax &
ballpos_next.z >= zmin & ballpos_next.z <= zmax & (ballpos.x < xmin |
ballpos.x > xmax))
#declare dir = -dir;
#declare hit=1;
#break
#end
#end
#declare cols=cols+1;
#end
#if (hit)
#break
#end
#declare rows=rows+1;
#end
These are the values at frame 219:
xmin = 18.65
xmax = 20.35
zmin = 3.65
zmax = 5.35
ballpos = <18.6344,0,4.38568>
ballpos_next = <18.7199,0,4.15076>
Now let's check both #if conditions:
Horizontal ("west-east") obstacles:
#if (ballpos_next.x >= xmin & ballpos_next.x <= xmax & ballpos_next.z
>= zmin & ballpos_next.z <= zmax & (ballpos.z < zmin | ballpos.z > zmax))
ballpos_next.x >= xmin TRUE
ballpos_next.x <= xmax TRUE
ballpos_next.z >= zmin TRUE
ballpos_next.z <= zmax TRUE
ballpos.z < zmin FALSE
ballpos.z > zmax FALSE
...so the following block should NOT be executed! But in fact it does!
Why? WHY?? WHY??? Am I too feeble-minded to understand this?!?
See you in Khyberspace!
Yadgar
Post a reply to this message
Attachments:
Download 'povigma_level0001_topview_0-25_340_newtexture.mp4.mpg' (1040 KB)
|
|