简体   繁体   中英

Allegro 5 ALLEGRO_BITMAP to text file

I'm currently working on a video game project in C++ using Allegro 5 as my graphics library. I store my graphic and font assets in subfolders within the root folder of the .exe. To use them in the program, I have an initGraphics() function that loads all the required assets through al_load_bitmap(), and then later free up the memory with al_destroy_bitmap(). This means however that when I eventually distribute my game, it'll be super easy for anyone to go into the install folder and just edit the graphics to be whatever, and I'm having trouble finding any kind of help regarding how to prevent this. What I was thinking maybe is some kind of program that I'd run on my own computer before distribution that loads the appropriate graphical assets, and somehow converts them into a .txt file, then changing the main game executable's 'initGraphics()' function to load and use those instead of just the raw .png files, but I'm not sure if this is possible. Any information about this type of conversion would be hugely appreciated, or alternatively a more reliable tested method that achieves the same effect. Thank you very much in advance!

While researching the internet I've found interesting solution:

Allegro5 uses PhysicsFS library to handle file archives. It does not support password protected archives, but you can calculate md5 for your assets archive and hardcode it into your program and then compare it on runtime (source - see more here) .

See this part of documentation of Allegro5.

Example explanation of md5 implementation is here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM