Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > protect resources (images) within a pygame-program

Reply
Thread Tools

protect resources (images) within a pygame-program

 
 
benjamin
Guest
Posts: n/a
 
      10-21-2004
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, lets say "game.dat", so they dot fly around in the programs
folder und can be edited by everyone.
Hope somebody can help me.
 
Reply With Quote
 
 
 
 
Mike C. Fletcher
Guest
Posts: n/a
 
      10-21-2004
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

benjamin wrote:

>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, lets say "game.dat", so they dot 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

 
Reply With Quote
 
 
 
 
Jeremy Bowers
Guest
Posts: n/a
 
      10-21-2004
On Thu, 21 Oct 2004 11:43:23 -0700, benjamin wrote:
> 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.

 
Reply With Quote
 
Max M
Guest
Posts: n/a
 
      10-21-2004
benjamin wrote:
> 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, lets say "game.dat", so they dot 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I include a server tag within a javascript parameter which is itself within a HTML element event? mark4asp ASP .Net 2 11-07-2006 06:23 AM
py2app question: Resources/Python -> Resources/lib/python2.4 Russell E. Owen Python 0 09-08-2006 08:08 PM
distributing resources within a module folder Max Kubierschky Python 0 03-18-2006 02:01 PM
Referring to a textbox within a web control within an aspx KatB ASP .Net 0 04-22-2005 07:14 PM
Accessing ISAM resources from within a WebService Ren M. Balslev ASP .Net Web Services 0 04-03-2004 12:35 AM



Advertisments