I’ve been trying out arrays in C to see how many blocks I can store for a level / game map. I decided to make an array of chars since they are guaranteed (For the most part) to be 8 bits on all platforms, and using bit shifts I split the 8 bits into 4 2 bit pieces of data. With 2 bits I have a total possibility of 4 different types of blocks for that block, that seems sufficient. I can always change the number of blocks per char to get even more types of blocks. And so if I have an array that has 64 chars, or a 64 byte array, that will hold 256 of my blocks because each char holds 4 blocks. I’ve scaled this up and I’ve been able to hold 1,073,741,824 blocks in 257Mbs of ram without my old computer choking or slowing down the rendering in the slightest (Not all the blocks are on the screen at the same time).
Yeah, I’m probably not gonna make a 1 billion block level, but it’s nice to know that I can.