I'm a real nitpick about memory consumption, I admit it.
I have a ton of information in a game I'm making, and the game is sectioned off into "cells". The game needs to store information about these cells.
Here's how I envision it working:
Variable 1 - Consumes 1 bit
Variable 2 - Consumes 1 bit
Variable 3 - Consumes 3 bits
Variable 4 - Consumes 3 bits
Variables 5-7 - Consume 8 bits each
Variables 8 & 9 - Consume 1 bit each
Alright, I'm slightly over 4 bytes there.. I want to constrict all of this into as little memory as possible because there will be potentially many thousands of cells that need their information stored. And I would really not like it if the saved files took up megabytes.
So, what I'm wondering about here... is how would I go about storing this information? According to help files, even the bool data type takes up a byte of memory (which doesn't make sense to me... but whatever)
I suppose I could manually flip each bit on considering each cell is only comprised of 26 bits, but that would be a hassle to accomplish.
Is there a method of bit shifting I could use here to move each variable into position and then simply OR them all together into a single value to be stored in memory?
Some example code would be appreciated if possible.
The one and only,