Position to array Index

When i create games that use a tile based map i usually create square maps so to get a tile from an array i use:

private int CoordinateToArray(Vector2 coordinate,int size){
        return (int)coordinate.x * size + (int)coordinate.y;
    }

But recently i created a map There’s not square. Is it possible to get an index from an array based from a coordinate from a non-square map from a single dimensional array and how if it is?

**0 1 2 3 4 5
*
0 - o o - - -

1 o o o o - -

2 o o o o o o

3 o o o o o o

4 - o o o o o

5 - o o o o -

This is the kind of thing that I imagine from your description (‘o’ is some tile, ‘-’ have no tile). Is this right, or is there something more complicated going on?

You can still store each tile based on its x-y values, you would just have holes in your array. Nothing wrong with that, but I don’t know how your logic would be compatible with nulls in the array.