5 Replies - 1684 Views - Last Post: 29 March 2013 - 06:11 AM Rate Topic: -----

#1 slidon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 09-February 13

playing a pygame game without installing it

Posted 15 March 2013 - 02:07 AM

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
Is This A Good Question/Topic? 0
  • +

Replies To: playing a pygame game without installing it

#2 Mekire  Icon User is offline

  • D.I.C Head

Reputation: 116
  • View blog
  • Posts: 212
  • Joined: 11-January 13

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.
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

Was This Post Helpful? 1
  • +
  • -

#3 slidon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 09-February 13

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.
Was This Post Helpful? 0
  • +
  • -

#4 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: playing a pygame game without installing it

Posted 26 March 2013 - 05:32 PM

Have you considered Portable Python?
Was This Post Helpful? 0
  • +
  • -

#5 slidon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 09-February 13

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?
Was This Post Helpful? 0
  • +
  • -

#6 slidon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 09-February 13

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 :angry2:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1