简体   繁体   English

Allegro 5 ALLEGRO_BITMAP到文本文件

[英]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. 我目前正在使用Allegro 5作为图形库的C ++视频游戏项目。 I store my graphic and font assets in subfolders within the root folder of the .exe. 我将图形和字体资源存储在.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(). 要在程序中使用它们,我有一个initGraphics()函数,该函数通过al_load_bitmap()加载所有必需的资产,然后再通过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. 我当时想的可能是某种程序,我在分发之前加载了适当的图形资产,然后在自己的计算机上运行,​​然后以某种方式将其转换为.txt文件,然后更改了游戏主要可执行文件的“ initGraphics()”函数加载和使用这些文件,而不只是原始的.png文件,但是我不确定是否可以这样做。 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. Allegro5使用PhysicsFS库处理文件存档。 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) . 它不支持受密码保护的档案,但是您可以为资产档案计算md5并将其硬编码到程序中,然后在运行时进行比较(来源-在此处查看更多)

See this part of documentation of Allegro5. 请参阅Allegro5文档的这一部分。

Example explanation of md5 implementation is here md5实现的示例说明在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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