2D Circular Linked List Data Grid

Thursday 30 August 2007 | Labels: , , , | |

In order to manage the visible bitmap data in the tile engine, I wrote this 2D Circular Linked List Data Grid. Once initialized the grid can hold n x n data items. The grid can be shifted left, right, up and down. As the grid is shifted, the items that fall off once side are added to the other, and automatically updated with new information. This demo illustrates the code. The red rectangle simulates the scroll window of the Tile Engine. The black/grey 4x4 grid represents the Bitmap Data Grid (Each smaller square would be a super tile of, say 5x5 normal tiles). As you move the red rectangle around with the cursor keys, the grid updates correspondingly. The important thing here is that there is only ever 4x4 Bitmap and BitmapData objects that get rotated around, updated and recycled.

Source.

0 comments: