protect resources (images) within a pygame-program

B

benjamin

A pygame/python game resource question
######################################
I wander whether there is any possibility to compile a bunch of
resources for a program, like images and soundfiles into a package
like, let´s say "game.dat", so they do´t fly around in the programs
folder und can be edited by everyone.
Hope somebody can help me.
 
M

Mike C. Fletcher

Using ResourcePackage may help you.

Basically this provides a sub-package of your project in which you dump
your resources. You then use mypackage.resources.filename_ext.data as
the source for your files. This allows your data-files to survive being
py2exe'd or zipped just as if they were regular Python modules (since
they are python modules). However, if you users want to edit them, they
need merely download ResourcePackage (and get a version of your package
that is stored in the filesystem (i.e. unzip your package)) and edit the
source files. If you want to just pack one copy in your game, then you
can pack the .py files and let the users extract them using
ResourcePackage's included scripts.

That is:

unzip yourproject
extract.py -f yourproject.resourcePackageName

To get the files in editable format.

If you mean, instead, that you want to have the files stored in some
commonly accessible location, rather than in the program files
hierarchy. You can store the files in the user's Application Data
folder (well, in a sub-directory of that).

http://resourcepackage.sourceforge.net/

HTH,
Mike
A pygame/python game resource question
######################################
I wander whether there is any possibility to compile a bunch of
resources for a program, like images and soundfiles into a package
like, let´s say "game.dat", so they do´t fly around in the programs
folder und can be edited by everyone.
Hope somebody can help me.
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
 
J

Jeremy Bowers

I wander whether there is any possibility to compile a bunch of
resources for a program, like images and soundfiles into a package
like, let´s say "game.dat", so they do´t fly around in the programs
folder

Valid; I'd suggest zipping them up and using the "zipfile" module,
standard w/ Python 2.3.
und can be edited by everyone.

It is unclear to me whether you *want* them editable, or if you don't.
(Does the "not" in "do't" [sic] apply to just the first clause, or both?)

If you *want* them editable, zip files are great because they are
reasonably standard, and you can just unzip them, make the changes, and
zip them up. For extra bonus points, have your program look for the
unzipped resources *first*, then look in the zip file. That way, you can
just unzip and make the changes, zipping only for final distribution.

If you *don't* want them editable, that's impossible. All local resources
can always be edited. Even the "big guys" haven't solved that problem.
 
M

Max M

benjamin said:
A pygame/python game resource question
######################################
I wander whether there is any possibility to compile a bunch of
resources for a program, like images and soundfiles into a package
like, let´s say "game.dat", so they do´t fly around in the programs
folder und can be edited by everyone.
Hope somebody can help me.

The easiest approach would probably be to load them into a whooping big
dictionar and save that as a pickle.

--

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top