XNA C#ゲームに水物理学を追加しています。これはタイルベース(グリッドシステム)です。
以前、これについて質問しました。でも実際にやってみたら思ったより簡単そうです、もう水が流れてきました。しかし、私の問題は、それが壁にぶつかったとき、私はそれが上がる必要があるということです。そして、列/行の最後のタイルの位置を取得する方法が必要です。それで、そのタイルが空か塗りつぶされているかを確認できます。
[W]
[W][W][W][B]
[B][B][B][B][B]
Should be...
[W][W][W][W][B]
[B][B][B][B][B]
など、そして私はそれに追加できるように列の終わりを取得する必要があります、例:
[W]
[W]
[W]
[B] [B]
[B] [B]
[B][W][B]
[B][W][B]
[B][B][B]
Should be
[W]
[B][W][B]
[B][W][B]
[B][W][B]
[B][W][B]
[B][B][B]
今のところ私のメソッドはそのようにそれらをスタックすることはできません
私がこれまでにやったことは...
private void UpdateWater()
{ // Calculate the visible range of tiles.
int left = (int)Math.Floor(cameraPosition / 16);
int right = left + 1024 / 16;
right = Math.Min(right, Width - 1);
int top = (int)Math.Floor(cameraPositionYAxis / 16);
int bottom = top + 768 / 16;
bottom = Math.Min(bottom, Height - 1);
//For Each tile on screen ///WATER CODE IS BELOW///
for (int y = top; y < bottom; ++y)
{
for (int x = left; x < right; ++x)
{
if (tiles[x, y].blockType.Name == "Water")
{
if (tiles[x, y + 1].blockType.Name == "Blank")
{
tiles[x, y ] = new Tile(BlockType.Blank, null, x,y );
tiles[x, y + 1] = new Tile(BlockType.Water, null, x, y + 1);
}
else if ((tiles[x + 1, y].blockType.Name != "Blank") && (tiles[x + 1, y].blockType.Name != "Water"))
{
}
else if ((tiles[x - 1, y].blockType.Name != "Blank") && (tiles[x - 1, y].blockType.Name != "Water"))
{
}
else
{
tiles[x, y] = new Tile(BlockType.Blank, null, x, y);
tiles[x - 1, y] = new Tile(BlockType.Water, null, x - 1, y);
}
}
}
}
}
私はまだおそらく「初心者」のコーダーと見なされています。助けていただければ幸いです。さらに情報や説明が必要な場合は、教えてください!
編集:多分私は水タイルの圧力パラメータが必要ですか?またはそうではありません...今これを理解しようとしています..まだスタッキングに少し問題があります。