With "getPixel()" coming in a future patch, what are people's thoughts of using images....
-
...to hold game assets? Not just graphics, but animation data, level data, music data, etc? How is this possible? It's simple really. A 32-bit RGBA pixel is nothing more than a 32-bit integer split into 4 8-bit components represented as Red, Green, Blue, and Alpha, ranging from 0 to 255. A 32-bit RGBA image could be imagined as an array of integers, or even like a loaded file where we can seek to certain parts to read/write. Sure, we use
plot
anduploadImage
using floats, and we'll likely be reading pixels with floats as well, but we can convert between floats and integers rather easily.What this would allow is being able to have that data available without having to reserve an array to hold it all at once, which would normally cut into the limited amount of memory we're given for variables. It also won't clutter the code screen. Reading/writing to an image one pixel at a time will take more time than reading/writing to a regular array because of the conversion factor, but that is the trade-off.
This wouldn't just limit it to a game's assets, but it would also open up the chance of user-created data. What I mean is that a person makes an program. That program can then create data that can then be used elsewhere. You know of the MML programs being made that will play back a string? Well, now imagine a program that makes the MML data, writes it to an image, and now that image can be placed into another project where the project can read that image, covert it to a string, then use that MML string. With it being an image, one could then place it in a project, and share that project with friends. Not meaning to toot my own horn, but that was one of the main goals of my MM2 PTC project from years ago with its level editor. People could make their own levels, write it to the program's graphic pages, then folks could save those pages to files, and then share online.
Of course, the one thing missing here to wrap it all up is being able to save the images from within our code, like a sort of
saveImage
function. Without that, we can't really have user-created data, and game assets would have to be created with the Image Editor and plotted manually, one pixel at a time. Not really a good way to go. -
That would be very useful, especially for storing rom and disk data
-
This kind of reminds me of whomever came up with encoding computer data in audio-- with this approach, we could encode game data in colors. Cool idea!