Add missing wall detection code

This commit is contained in:
EchoHowardLam 2019-01-10 10:04:00 +08:00
parent b2203a6614
commit 6056c5f600

View File

@ -205,9 +205,9 @@ void Air::update_air(void)
vy[y][x] *= AIR_VLOSS;
vx[y][x] += dx*AIR_TSTEPV;
vy[y][x] += dy*AIR_TSTEPV;
if (bmap_blockair[y][x] || (bmap_blockair[y][x+1] && vx[y][x] > 0))
if (bmap_blockair[y][x] || bmap_blockair[y][x+1])
vx[y][x] = 0;
if (bmap_blockair[y][x] || (bmap_blockair[y+1][x] && vy[y][x] > 0))
if (bmap_blockair[y][x] || bmap_blockair[y+1][x])
vy[y][x] = 0;
}
@ -259,7 +259,10 @@ void Air::update_air(void)
{
tx += stepX;
ty += stepY;
if (bmap_blockair[(int)(ty+0.5f)][(int)(tx+0.5f)])
if (bmap_blockair[(int)(ty+0.5f)][(int)(tx+0.5f)] ||
bmap_blockair[(int)(ty+0.5f)][(int)(tx+1.5f)] ||
bmap_blockair[(int)(ty+1.5f)][(int)(tx+0.5f)] ||
bmap_blockair[(int)(ty+1.5f)][(int)(tx+1.5f)])
{
tx -= stepX;
ty -= stepY;
@ -277,8 +280,11 @@ void Air::update_air(void)
j = (int)ty;
tx -= i;
ty -= j;
if (!bmap_blockair[y][x] && i>=2 && i<=XRES/CELL-3 &&
j>=2 && j<=YRES/CELL-3)
if (!bmap_blockair[y][x] &&
!bmap_blockair[y][x+1] &&
!bmap_blockair[y+1][x] &&
!bmap_blockair[y+1][x+1] &&
i>=2 && i<=XRES/CELL-3 && j>=2 && j<=YRES/CELL-3)
{
dx *= 1.0f - AIR_VADV;
dy *= 1.0f - AIR_VADV;