Hi folks,
bspeers here. I'm new to GE but not to scripting engines. I'm working on a sequel to Flags of Doom, a game nobody here could have possibly heard of. I like that.
I'm working on a save-system for a collection-based game with potentially 1000 or more collectables. Think a non-linear Jumpman (C64 era) with about 100 levels. Flags of Doom was 120 levels, so this isn't a big leap.
Now storing the actor's status, inventory, score, etc is all trivial as far as I understand GE's built in save system, but I also need to track whether each flag has been collected. It's not enough to simply count how many have been collected either. I want, upon loading the game, for you to be able to return to an uncompleted room and have your progress resume. I don't want to record every enemy defeated, every jump or anything like that, but do want to record whether any particular flag or other collectable has been taken and draw only those that haven't been snagged. The flags are placed strategically around each room, so knowing whether THAT PARTICULAR flag has been grabbed is essential.
Now I could create an array representing every flag, but that would mean having to declare possibly 1000 or more variables. I want to streamline my data.
My thought is that I could use a bitwise operator to isolate digits of an int and then have a calculation that adds a specified and checkable amount that is then compared via >> and <<. I'm not an expert on programming, but I believe this could be used to store as many as 27 different flags in a standard 9 digit int. For example, if you collect flag 1, add 1 to flagcount. If you get flag two, add 3. If you get flag 3 add 5. If you get flag 4, add 10. Flag, 5, 30, 6. 50 and so on. This way you could do only a couple checks and know whether particular flags were taken from individual levels. If the first digit is = to 4, we know flags 1 and 2 have been taken. If it's equal to 9, we know flags 1, 2, and 3. So on and so forth.
As you can probably tell, however, I don't really understand how bitwise operators work. In fact, I'm not sure they can be used to isolate non-binary integers in this way at all.
Does anyone A) have any advice on how to make this method work, or B) a simpler method for recording large amounts of data in one or two integers? Something that can be saved in GE games.
Thanks in advance!
tldr edition: how to store multiple boolean values in one int?