2
私は弾丸衝突のプロジェクトで学校に通っています。 行が真っ直ぐだがオプションがbulletspreadの場合は問題ありません。 したがって、弾丸が与えられる直線の点が与えられますが、弾丸の衝突で角度と距離からランダムな点を作成する方法はありますか? ここは弾丸衝突のコードです。距離と角度からランダムな点を得るには?
private void setEndPoint()
{
endPoint = new Point(beginPoint.x, beginPoint.y);
switch (direction)
{
default:
break;
case UP:
while (endPoint.y > 0)
{
if (tileEmptyCheck(endPoint.x, endPoint.y))
{
endPoint.y -= 1;
}
else
{
fire();
break;
}
}
break;
case LEFT:
while (endPoint.x > 0)
{
if (tileEmptyCheck(endPoint.x, endPoint.y))
{
endPoint.x -= 1;
}
else
{
fire();
break;
}
}
break;
case DOWN:
while (endPoint.y < map.getHeightInTiles() * GameState.TILESIZE)
{
if (tileEmptyCheck(endPoint.x, endPoint.y))
{
endPoint.y += 1;
}
else
{
fire();
break;
}
}
break;
case RIGHT:
while (endPoint.x < map.getWidthInTiles() * GameState.TILESIZE)
{
if (tileEmptyCheck(endPoint.x, endPoint.y))
{
endPoint.x += 1;
}
else
{
fire();
break;
}
}
break;
case RIGHT_UP:
while (endPoint.y > 0 && endPoint.x < map.getWidthInTiles() * GameState.TILESIZE)
{
if (tileEmptyCheck(endPoint.x, endPoint.y))
{
endPoint.y -= 1;
endPoint.x += 1;
}
else
{
fire();
break;
}
}
break;
case RIGHT_DOWN:
while (endPoint.y < map.getHeightInTiles() * GameState.TILESIZE &&
endPoint.x < map.getWidthInTiles() * GameState.TILESIZE)
{
if (tileEmptyCheck(endPoint.x, endPoint.y))
{
endPoint.y += 1;
endPoint.x += 1;
}
else
{
fire();
break;
}
}
break;
case LEFT_DOWN:
while (endPoint.y < map.getHeightInTiles() * GameState.TILESIZE &&
endPoint.x > 0)
{
if (tileEmptyCheck(endPoint.x, endPoint.y))
{
endPoint.y += 1;
endPoint.x -= 1;
}
else
{
fire();
break;
}
}
break;
case LEFT_UP:
while (endPoint.y > 0 &&
endPoint.x > 0)
{
if (tileEmptyCheck(endPoint.x, endPoint.y))
{
endPoint.y -= 1;
endPoint.x -= 1;
}
else
{
fire();
break;
}
}
break;
}
}
底角と広がり角の違いは何ですか? –
@TiesTheunissen私は自分の答えを更新しました – ControlAltDel