问题描述
对于制作独立可执行文件的问题,有很多很好的答案,但是我不知道如何将艺术资产(或动态加载的文件)打包到其中.我为什么要这样做?因为分发一个简单的(扔掉的)游戏完全可以放在一个没有安装程序的单个可执行文件中就很好了.
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)避免使用有利于内容生成的艺术品.我可以使用一个程序,将一个简单的精灵转换为RLE像素颜色列表,该列表位于python脚本中.由于这是一个脚本,因此将使用打包工具将其绑定到exe中.对吧?
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)使用某种自解压存档,可以将目录结构转储到temp目录中(或可能在内存中?),然后自动运行程序的入口点.
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.
我想做的事情有意义吗?第二种选择似乎更加明智,但是我不确定将使用哪些工具来通过python和pygame完成它.我用过py2exe,但是它只打包了python脚本和导入的模块.
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.
此线程使我认为您可以告诉打包实用程序包括程序数据以及相关性.是真的吗?
This thread makes me think that you can tell the packaging utility to include program data along with the dependencies. Is that true?
推荐答案
游戏开发不是专业领域,但是如果您还没有签出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.
希望这会有所帮助
这篇关于将程序*和*动态加载文件到单个可执行文件中? (python + pygame,或与语言无关)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!