_GRID[800,480]The grid contains data of type _node, which is setup as follows:
public class _node
{
public _type _TYPE=_type._NULL;
public int _ID=-1;
}
In addition i have aList<Sprite> SpritesFor holding all the sprite data. Right now I only have sand & Water working, but i want the sand to sink if water is direcly above it. I figured the best way to go about this, is to check if a Sand Element has A Water Element directly below it then switch the positions. Im Checking like this:
if (_Grid[_x, _y + 1]._TYPE != _type._NULL && (_Grid[_x, _y + 1]._TYPE != _type._SAND))
{
if (_Grid[_x, _y + 1]._TYPE == _type._WATER)
{
_sprite _TEMPS = _sprites[_Grid[_x, _y + 1]._ID];
_sprite._switch(Con,ref _Grid, ref _TEMPS);
_sprites[_Grid[_x, _y + 1]._ID] = _TEMPS;
}
}
So first it makes sure there is Something (that's not sand) below it. Then it checks to see if its water. Then it Creates a temporary Sprite to be Passed to the Switch Method if it Is Water. Once that's done It updates the Sprite list Changing it to the Temporary Sprite.
Switch Method:
public void _switch(ContentManager Con, ref _node[,] _grid ,ref _sprite _Sprite)
{
_sprite _Temp = new _sprite(Con,new Vector2(_Sprite._POSITION.X,_Sprite._POSITION.Y),
_Sprite._TYPE,_Sprite._COLOR,_Sprite._ID);
_node _Node = _grid[(int)_Sprite._POSITION.X, (int)_Sprite._POSITION.Y];
_grid[(int)_Sprite._POSITION.X, (int)_Sprite._POSITION.Y] = _grid[(int)_POSITION.X, (int)_POSITION.Y];
_grid[(int)_POSITION.X, (int)_POSITION.Y] = _Node;
_Sprite._POSITION = _POSITION;
_Sprite._ID = _ID;
_Sprite._COLOR = _COLOR;
_Sprite._TYPE = _TYPE;
_POSITION = _Temp._POSITION;
_ID = _Temp._ID;
_COLOR = _Temp._COLOR;
_TYPE = _Temp._TYPE;
}
Fairly straight forward, it takes the Data from the Temporary sprite, and Switches it with the sprite that is currently being processed. Or at least it should, Ive tried 1000 things but when i spawn sand above water it just sits on top. For clarity ive included the game below if you want to see what i mean (Just spawn water then sand above it). All im trying to figure out is WHY they aren't switching, any help is appreciated. Thank you.



















