Stand Alone Single File Simple Game Packing

I just noticed this recipe is nowhere here, so im sharing it,
its oriented for people that understand basic python. :slight_smile:

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/</b>

<b>echo "def main(): print('MY GAME RUNS')" &gt; my_game_folder/</b>

<b>cat my_game_folder/</b>
def main(): print('MY GAME RUNS')

<b>echo "from my_game_folder import game" &gt;</b>

<b>echo "game.main()" &gt;&gt;</b>

<b>cat </b>
from my_game_folder import game


<b>zip -r my_game_folder/</b>
  adding: (deflated 7%)
  adding: my_game_folder/ (stored 0%)
  adding: my_game_folder/ (stored 0%)
  adding: my_game_folder/ (stored 0%)


<b>( echo -e '#!/usr/bin/env python
# -*- coding: utf-8 -*-
' ; cat ) &gt; standalone_game</b>

<b>chmod +x standalone_game</b>


<b>cp standalone_game /home/juan/</b>


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

#!/usr/bin/env python

-- coding: utf-8 --

to the 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 my_game_folder/

( echo -e '#!/usr/bin/env python
# -*- coding: utf-8 -*-
' ; cat ) &gt; 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… :slight_smile:

I make this on any OS i use, it runs on Linux, BSD, MacOsX, etc