I just noticed this recipe is nowhere here, so im sharing it,
its oriented for people that understand basic python.
Below a command line session with step by step how to create a
" Stand Alone Single File Simple Game Packing "
<b>mkdir my_game_folder</b>
<b>touch my_game_folder/__init__.py</b>
<b>echo "def main(): print('MY GAME RUNS')" > my_game_folder/game.py</b>
<b>cat my_game_folder/game.py</b>
def main(): print('MY GAME RUNS')
<b>echo "from my_game_folder import game" > __main__.py</b>
<b>echo "game.main()" >> __main__.py</b>
<b>cat __main__.py </b>
from my_game_folder import game
game.main()
<b>python __main__.py</b>
MY GAME RUNS
<b>zip -r file.zip __main__.py my_game_folder/</b>
adding: __main__.py (deflated 7%)
adding: my_game_folder/ (stored 0%)
adding: my_game_folder/__init__.py (stored 0%)
adding: my_game_folder/game.py (stored 0%)
<b>python file.zip</b>
MY GAME RUNS
<b>( echo -e '#!/usr/bin/env python
# -*- coding: utf-8 -*-
' ; cat file.zip ) > standalone_game</b>
<b>chmod +x standalone_game</b>
<b>./standalone_game</b>
MY GAME RUNS
<b>cp standalone_game /home/juan/</b>
<b>/home/juan/standalone_game</b>
MY GAME RUNS
Im on /tmp for no reason, this can be done anywhere…,
even more, the stand alone file generated is Portable and Portatil.
Notice that inside " my_game_folder " can be from 1 to 999999999999999999 files,
of any kind, Videos, Textures, Sounds, Other .blend, python scripts to decrypt, etc.
def main(): print(‘MY GAME RUNS’) simulates the source code and stuff of a giant Game.
echo -e '#!/usr/bin/env python
-- coding: utf-8 --
’ ; cat file.zip
appends:
#!/usr/bin/env python
-- coding: utf-8 --
to the file.zip header, so it runs for itself, and then write everything into standalone_game
chmod +x standalone_game makes standalone_game an executable program
./standalone_game runs the game, you can delete all other files if you want to.
./standalone_game can run from everywhere, from Terminal, from Shortcut icon,
no install needed, no administrative permissions.
Notice there are non-required extra steps so you can actually understand whats happening
and not just copy&paste-ing some weirdo voodoo, here the only mandatory steps:
<b>zip -r file.zip __main__.py my_game_folder/
( echo -e '#!/usr/bin/env python
# -*- coding: utf-8 -*-
' ; cat file.zip ) > standalone_game
chmod +x standalone_game</b>
You can do this via GUI, if you want to, i do it on command line because its easy to me to explain.
I hope you find this fun to hack…