protect resources (images) within a pygame-program

Discussion in 'Python' started by benjamin, Oct 21, 2004.

  1. benjamin

    benjamin Guest

    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.
    benjamin, Oct 21, 2004
    #1
    1. Advertising

  2. 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, 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
    Mike C. Fletcher, Oct 21, 2004
    #2
    1. Advertising

  3. 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.
    Jeremy Bowers, Oct 21, 2004
    #3
  4. benjamin

    Max M Guest

    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, 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
    Max M, Oct 21, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    718
    Ryan Stewart
    Mar 5, 2005
  2. jaYPee
    Replies:
    30
    Views:
    12,403
    Hywel Jenkins
    Jun 3, 2004
  3. Bill
    Replies:
    8
    Views:
    552
  4. CPUFreak91
    Replies:
    1
    Views:
    342
    Ben Sizer
    Oct 5, 2005
  5. rantingrick

    [pygame-bug] Pygame.cdrom bug

    rantingrick, Jan 30, 2011, in forum: Python
    Replies:
    1
    Views:
    303
    Benjamin Kaplan
    Jan 30, 2011
Loading...

Share This Page