article

Rotating an array using C#

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.

avatar
Richard Moss
article

Converting 2D arrays to 1D and accessing as either 2D or 1D

This article shows how you can store 2D data in a 1D array using row-major order and convert locations between the two.

avatar
Richard Moss