Ignore:
Timestamp:
10/17/09 02:05:35 (10 years ago)
Author:
Kaydeth_parpg
Message:

Ticket #2: Patch by Kaydeth. Updated the classes in local_loaders and utilities directories to correct some obvious discrepancies with our coding standard. comment[s:trac, t:2] fixes[s:trac, t:2]

File:
1 edited

Legend:

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

    r147 r328  
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/> 
    1717 
    18 import sys, pygame 
     18import sys 
     19import pygame 
    1920 
    2021# place defines here 
     
    2829 
    2930class TileImage: 
    30     def __init__(self, picture, name, yoff): 
     31    def __init__(self, picture, name, y_off): 
    3132        self.image = picture 
    3233        self.filename = name 
    33         self.y_offset = yoff 
     34        self.y_offset = y_off 
    3435 
    35 def writeXML(name, yoff): 
     36def writeXML(name, y_off): 
    3637    """Write the XML file as well 
    3738       Always the same small file so we do it automatically""" 
     
    5152    x_file.write('''" direction="0"''') 
    5253    x_file.write(''' y_offset="''') 
    53     x_file.write(yoff) 
     54    x_file.write(y_off) 
    5455    x_file.write('''" />\n''') 
    5556    # the \n\n is ESSENTIAL otherwise the XML parser in FIFE craps out! 
     
    5960def stitchImages(files, width, height): 
    6061    """Put the images together and output them to stitched.png""" 
    61     new_image=pygame.Surface((width, height), pygame.SRCALPHA, 32) 
    62     xpos = 0 
     62    new_image = pygame.Surface((width, height), pygame.SRCALPHA, 32) 
     63    x_pos = 0 
    6364    for i in files: 
    64         new_image.blit(i.image, (xpos, 0)) 
    65         xpos += i.image.get_width() 
    66     pygame.image.save(new_image,"stitched.png") 
     65        new_image.blit(i.image, (x_pos, 0)) 
     66        x_pos += i.image.get_width() 
     67    pygame.image.save(new_image, "stitched.png") 
    6768     
    6869def saveFiles(files): 
     
    103104    # the starting point for the grab is always the middle of the image 
    104105    height = (image.get_height() / 2) + (TILE_HEIGHT / 2) 
    105     xpos = 0 
     106    x_pos = 0 
    106107    file_counter = 0 
    107108    tiles = [] 
    108109    height_adjust = 0 
    109     yoff_next = -((height - TILE_HEIGHT) / 2) 
     110    y_off_next = -((height - TILE_HEIGHT) / 2) 
    110111    for t in data: 
    111         yoff = yoff_next 
     112        y_off = y_off_next 
    112113        if(t == 'm'): 
    113114            # switchback, so this tile must fill the whole width 
    114115            width += TILE_WIDTH / 2 
    115116            height_adjust = TILE_HEIGHT / 2 
    116             yoff_next += (TILE_HEIGHT / 4) + (TILE_HEIGHT / 2) 
     117            y_off_next += (TILE_HEIGHT / 4) + (TILE_HEIGHT / 2) 
    117118            xoff = 0 
    118119        elif(t == 'r'): 
     
    120121            width = TILE_WIDTH / 2 
    121122            height_adjust = - (TILE_HEIGHT / 2) 
    122             yoff_next += TILE_HEIGHT / 4 
     123            y_off_next += TILE_HEIGHT / 4 
    123124            xoff = TILE_WIDTH / 2 
    124125        elif(t == 'l'): 
     
    126127            width = TILE_WIDTH / 2 
    127128            height_adjust = TILE_HEIGHT / 2 
    128             yoff_next -= TILE_HEIGHT / 4 
     129            y_off_next -= TILE_HEIGHT / 4 
    129130            xoff = 0 
    130131        else: 
     
    137138            height += 1 
    138139        # build the new surface 
    139         new_surface = pygame.Surface((TILE_WIDTH, height), pygame.SRCALPHA, 32) 
     140        new_surface = pygame.Surface((TILE_WIDTH, height), \ 
     141                                     pygame.SRCALPHA, 32) 
    140142        # now blit a strip of the image across 
    141         new_surface.blit(image, (0+xoff, 0), pygame.Rect(xpos, 0, width, height)) 
     143        new_surface.blit(image, (0+xoff, 0), pygame.Rect(x_pos, 0, \ 
     144                                                         width, height)) 
    142145        # store the image for later 
    143         tiles.append(TileImage(new_surface, 
    144             filename + chr(ord('a')+file_counter) + ".png",yoff)) 
     146        tiles.append(TileImage(new_surface, \ 
     147            filename + chr(ord('a')+file_counter) + ".png",y_off)) 
    145148        file_counter += 1 
    146149        # amend variables 
    147         xpos += width 
     150        x_pos += width 
    148151        height += height_adjust 
    149152    return tiles 
     
    164167    # validate each data statement 
    165168    for i in data: 
    166         if((i != 'l')and(i != 'r')and(i != 'm')and(i.isdigit()==False)): 
     169        if((i != 'l')and(i != 'r')and(i != 'm')and(i.isdigit() == False)): 
    167170            # some issue 
    168171            print "Error: Can't decode tile string structure" 
     
    172175        image = pygame.image.load(filename) 
    173176    except(pygame.error): 
    174         print "Error: Couldn't load",filename 
     177        print "Error: Couldn't load", filename 
    175178        return False         
    176179    # split into seperate files 
Note: See TracChangeset for help on using the changeset viewer.