将程序*和*动态加载的文件打包到单个可执行文件中? (python + pygame,或与语言无关)
关于制作独立可执行文件的问题有很多很好的答案,但我不知道如何将艺术资源(或动态加载的文件)打包到其中。我为什么要这样做?因为如果能够分发一个完全位于单个可执行文件中且无需安装程序的简单(一次性)游戏,那就太棒了。
据我从搜索中得知,有两种基本方法。
1)避免使用有利于内容生成的艺术资产。我可以有一个程序,将一个简单的精灵转换成一个存在于 python 脚本中的 RLE 像素颜色列表。因为它是一个脚本,所以它会通过打包工具绑定到exe中。正确的?
2)使用某种自解压存档,可以将目录结构转储到临时目录(或者可能到内存中?),然后自动运行程序的入口点。
我想做的事情有意义吗?第二个选项似乎更明智,但我不确定使用哪些工具来使用 python 和 pygame 来完成它。我使用过 py2exe,但它只打包 python 脚本和导入的模块。
编辑:
此线程 让我认为您可以告诉打包实用程序包含程序数据以及依赖项。这是真的吗?
There are plenty of great answers to questions about making a standalone executable, but I can't figure out how to pack art assets (or dynamically loaded files) into it as well. Why would I want to do this? Because it would be great to distribute a simple (throw away) game that lives entirely in a single executable with no installer.
As far as I can tell from searching, there are two basic approaches.
1) Avoid art assets in favor of content generation. I could have a program that turns a simple sprite into a RLE pixel-color list that lives in a python script. Since it's a script, it would get bound up into the exe with a packaging tool. Right?
2) Use some kind of self-extracting archive that can dump the directory structure into a temp directory (or maybe into memory?), then automatically run the entry point of the program.
Does what I'm trying to do make sense? The second option seems so much more sensible, but I'm not sure which tools would be used to accomplish it with python and pygame. I've used py2exe, but it only packaged python scripts and imported modules.
EDIT:
This thread makes me think that you can tell the packaging utility to include program data along with the dependencies. Is that true?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
游戏开发不是专业领域,但如果您还没有检查过 py2exe,我强烈建议您这样做。在我看来,任何和所有脚本导入语句都将由 py2exe 处理。
希望这有帮助
Game development is not field of expertise, but if you haven't already checked out py2exe, I would strongly recommend that you do. It seems to me that any and all scripting import statements will be taken care of by py2exe.
Hope this helps