I've recently been working on a number of small test programs for the different sections which make up a game I'm planning on writing. One of these test systems involved a series of polyominoes which I needed to rotate. Internally, the data for these shapes are stored as a simple boolean array, which I access as though it were two dimensions. This article and corresponding source code download describe how to rotate 2D rectangular arrays (or 1D arrays that masquerade as 2D) in 90° intervals clockwise or anti-clockwise.
Entries tagged with 'array' Articles and information on C# and .NET development topics
This article shows how you can store 2D data in a 1D array using row-major order and convert locations between the two.