Changeset 81


Ignore:
Timestamp:
06/02/09 09:49:50 (10 years ago)
Author:
maximinus_parpg
Message:

Slowly starting to build the code to auto-split buildiings.
/utilities/gfxsplit.py will be broken for a few updates.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PARPG/utilities/gfxsplit.py

    r67 r81  
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/> 
    1717 
    18 import sys,pygame 
     18import sys, pygame 
    1919 
    2020# place defines here 
     
    101101    return tiles 
    102102             
    103 def convertFiles(filename): 
     103def convertFiles(filename, txt_data): 
    104104    """Take a file, slice into seperate images and then save these new images 
    105105       as filename0, filename1 ... filenameN 
    106        Returns True if everything worked""" 
    107     # first off, load the file 
     106       Returns True if everything worked 
     107       The second string gives the offsets from left to right. The first tile 
     108       on the LHS MUST be in the centre of the image""" 
     109    # first we need to ensure that the data sent is correct. split it up first 
     110    data=txt_data.split(",") 
     111    if(len(data) < 2): 
     112        print "Error: Invalid tile data layout" 
     113        return False 
     114     
     115    # validate each data statement 
     116    for i in data: 
     117        print i 
     118     
     119    print "sdfsdf" 
     120     
     121    return True 
     122     
     123    print "sdfsdf" 
     124     
     125    # check the length of the data 
     126    length=(TILE_WIDTH / 2) * (len(data) + 1) 
     127    # then load the file 
    108128    try: 
    109129        image=pygame.image.load(filename) 
     
    123143if __name__=="__main__": 
    124144    # check we have some options 
    125     if(len(sys.argv) < 2): 
    126         sys.stderr.write("Error: No image given!\n") 
     145    if(len(sys.argv) < 3): 
     146        sys.stderr.write("Error: Not enough data given\n") 
    127147        sys.exit(False) 
    128148    # ok, so init pygame and do it 
    129149    pygame.init() 
    130     sys.exit(convertFiles(sys.argv[1])) 
     150    sys.exit(convertFiles(sys.argv[1], sys.argv[2])) 
    131151 
Note: See TracChangeset for help on using the changeset viewer.