Hi, I am creating a game in pygame. What I wanted was for it to be playable in browser but it doesn't look like thats possible, I am happy to have the game downloadable but it would need to be playable without installing pygame. Anyone know if thats possible. Secondly how can I make the folder of files into an application? its not very user friendly to have to run main.py.
Thanks in advance
Slidon
playing a pygame game without installing it
Page 1 of 15 Replies - 931 Views - Last Post: 29 March 2013 - 06:11 AM
Replies To: playing a pygame game without installing it
#2
Re: playing a pygame game without installing it
Posted 15 March 2013 - 05:23 AM
There is a python module called py2exe you can use, but it is actually a bit tricky to get to work with pygame.
This will create a windows executable for your program if all goes well. You will still have to include your graphics and sound and whatnot though, in the same place that your main file would expect to find them.
As for organizing your folder of files, that is a different matter. The above script should bundle all your source into one file, but for python in general I would say the best method is to put your individual files in a package (a folder including a blank file named __init__.py) within your main folder). Then you can create a single file with the same name as your program in the top folder which simply imports the package and calls the main function.
Take a look at the structure of this program (a recent rewrite of my first Pygame from a couple years ago) for an example:
Double Cross
The source downloads demonstrate the packaging organization I talked about and the windows executables were created with the aforementioned py2exe module.
Cheers,
-Mek
Spoiler
The above script worked for me; just replace "Your_Main_File_Name_Here.pyw" with your main file name. Also see the first comment line in the script. You may or may not have to download the py2exe module before hand. It might have come with your Python distribution. Also I would recommend against using sysfont in your games; package any desired fonts with your game to avoid potential problems.This will create a windows executable for your program if all goes well. You will still have to include your graphics and sound and whatnot though, in the same place that your main file would expect to find them.
As for organizing your folder of files, that is a different matter. The above script should bundle all your source into one file, but for python in general I would say the best method is to put your individual files in a package (a folder including a blank file named __init__.py) within your main folder). Then you can create a single file with the same name as your program in the top folder which simply imports the package and calls the main function.
Take a look at the structure of this program (a recent rewrite of my first Pygame from a couple years ago) for an example:
Double Cross
The source downloads demonstrate the packaging organization I talked about and the windows executables were created with the aforementioned py2exe module.
Cheers,
-Mek
This post has been edited by Mekire: 15 March 2013 - 07:35 AM
#3
Re: playing a pygame game without installing it
Posted 26 March 2013 - 05:55 AM
Hi, sorry I haven't been able to get online for a some time. I have downloaded the py2exe module but is there a command to find my python path?
I have a folder in applications called macpython2.5 but it doesn't seem to be in the path.
I have a folder in applications called macpython2.5 but it doesn't seem to be in the path.
#4
Re: playing a pygame game without installing it
Posted 26 March 2013 - 05:32 PM
Have you considered Portable Python?
#5
Re: playing a pygame game without installing it
Posted 29 March 2013 - 03:15 AM
I probably should know this but what are you suggesting I do with it?
#6
Re: playing a pygame game without installing it
Posted 29 March 2013 - 06:11 AM
hmm it looks like portable python is not available for mac osx
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|