Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7872611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:15:15+00:00 2026-06-03T02:15:15+00:00

Im adding water physics to my XNA C# game, it is Tile based (grid

  • 0

Im adding water physics to my XNA C# game, it is Tile based (grid System).

I asked a question about this before. But I actually attempted it and it seems easier than I thought, I already got some water to flow. But My problem is, When it hits a wall, I need it to go up. And I need a way to get the position of the last tile on the column/row So I can check if its empty or filled

      [W]
   [W][W][W][B]
[B][B][B][B][B]
Should be...

[W][W][W][W][B]
[B][B][B][B][B]

etc, and I need to get the end of a column so I can add to it, ex:

   [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]

Right now my method cant stack them like that

What Ive done so far is…

 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);

                    }
                }
            }
        }
    }

I’m still probably considered a “novice” coder, any help is appreciated!
If you need any more info or clarification, Please tell!

EDIT: Maybe I need a Pressure parameter for Water tiles? Or not… Trying to figure this out now.. still having a little trouble with the stacking.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:15:18+00:00Added an answer on June 3, 2026 at 2:15 am

    Are you trying to simulate something resembling real physics, or something more like “Boulderdash” physics? If the latter, I would suggest that you might want to play around with different approaches to see what “feels” right; I’d suggest that instead of thinking in terms of “pressure”, you think in terms of volume, assigning each cell a value from e.g. 1/8 full to completely full. Then on each movement frame perform the following two operations:

    1. From bottom to top, if a cell which contains water is over a cell which could contain water but is not full, move as much water as can be moved from the upper cell to the lower one.
    2. From bottom to top, for each cell which contains water, if the cell below cannot accommodate any more water, transfer 1/4 of the ‘starting amount’ of water to each side if there’s room.

    I’d guess that performing those two steps every frame should probably yield some reasonable-looking water effects. They won’t represent anything remotely resembling real physics, but for a lot of platform games, playability is more important then realism.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Adding Exceptional Handling is a good practise, but I have a doubt, In our
Adding the row one by one in the button click.. (i tried but its
Adding strings localization files in iPhone bundle is very simple and perfectly fine but
Adding files to .hgignore will prevent them from being tracked. But we have some
Adding Multiple series to the ComboChart with different graph types is straightforward, but I
Adding an image to a UINavigationItem's titleView is pretty trivial, but when I push
When adding this code to a simple calculator program I receive the error message
Adding a comment such as this: // TODO: Refactor this code ...creates a task
Adding ribbon controls seems strightforward enough, but how do I make it so that
After-edit: Wow, this question go long. Please forgive =\ I am creating a new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.