Пример #1
0
    def __init__(self, loaderTile, surface, xIndex, yIndex, layer):
        '''
        Constructor
        '''
        
        GameTile.__init__(self, loaderTile, surface, xIndex, yIndex, layer)
        
        # ghetto add config from editor
        # note only Y is used
         
        if self.properties.has_key('velocity') and self.properties['velocity'].strip():
            self.BounceVelocity = Vector((0, int(self.properties['velocity'])))
        else:
            self.BounceVelocity = Vector((0, -850))
        
        # tile test animation
        """
        anim = Animation('../resources/tiles/tile_arrow_anim.png', pygame.Rect(0, 0, 32, 32), 3, 9, -1, None, True)
        self._animations['up'] = anim
        self._drawOffsets[anim] = Vector((0, 0))
        
        anim2 = Animation('../resources/tiles/tile_arrow_anim.png', pygame.Rect(0, 0, 32, 32), 3, 0, 0, None, True)
        self._animations['bounce'] = anim2
        self._drawOffsets[anim2] = Vector((0, 0))
        """

        self._sounds['bounce'] = Sound('../content/sounds/boing.ogg', Constants.GameConstants.SOUND_VOLUME)
Пример #2
0
    def __init__(self, loaderTile, surface, xIndex, yIndex, layer):
        '''
        Constructor
        '''
        
        GameTile.__init__(self, loaderTile, surface, xIndex, yIndex, layer)
        
        #sheetPath, frameRect, totalFrames, frameDelay=0, holdFrame=-1, colorKey=None, alpha=False
        # sheet path, frame size, total frames, frame delay, hold frame, key color 
        sheetPath = os.path.realpath(os.path.join(self.Layer.Map.FilePath, self.properties['sheet path'].strip()))
        
        if self.properties.has_key('frame size') and self.properties['frame size'].strip():
            frameSize = StringConversions.StringToIntTuple(self.properties['frame size'])
        else:
            frameSize = (self.Width, self.Height)
        frameRect = pygame.Rect((0, 0), frameSize)
            
        totalFrames = int(self.properties['total frames'])
        
        if self.properties.has_key('frame delay') and self.properties['frame delay'].strip():
            frameDelay = int(self.properties['frame delay'])
        else:
            frameDelay = 0
            
        if self.properties.has_key('hold frame') and self.properties['hold frame'].strip():
            # in editor, things are 1 based
            holdFrame = int(self.properties['hold frame']) - 1
        else:
            holdFrame = -1
            
        if self.properties.has_key('key color') and self.properties['key color'].strip():
            keyColor = pygame.Color(StringConversions.StringToIntTuple(self.properties['key color']))
            alpha = False
        else:
            keyColor = None
            alpha = True
        
        if self.properties.has_key('offset') and self.properties['offset'].strip():
            offset = StringConversions.StringToIntTuple(self.properties['offset'])
        else:
            offset = (0, 0)
            
        anim  = Animation(sheetPath, frameRect, totalFrames, frameDelay, holdFrame, keyColor, alpha)
        self._animations['anim'] = anim
        self._drawOffsets[anim] = Vector(offset)
        
        # tile test animation
        """
        anim = Animation('../resources/tiles/tile_arrow_anim.png', pygame.Rect(0, 0, 32, 32), 3, 9, -1, None, True)
        self._animations['up'] = anim
        self._drawOffsets[anim] = Vector((0, 0))
        
        anim2 = Animation('../resources/tiles/tile_arrow_anim.png', pygame.Rect(0, 0, 32, 32), 3, 0, 0, None, True)
        self._animations['bounce'] = anim2
        self._drawOffsets[anim2] = Vector((0, 0))
        """

        self._sounds['bounce'] = Sound('../content/sounds/boing.ogg', Constants.GameConstants.SOUND_VOLUME)
        
        self.PlayAnimation('anim')
Пример #3
0
    def __init__(self, loaderTile, surface, xIndex, yIndex, layer):
        '''
        Constructor
        '''
        
        GameTile.__init__(self, loaderTile, surface, xIndex, yIndex, layer)
        
        # tile test animation
        
        """
        anim = Animation('../resources/tiles/tile_arrow_anim.png', pygame.Rect(0, 0, 32, 32), 3, 9, -1, None, True)
        self._animations['up'] = anim
        self._drawOffsets[anim] = Vector((0, 0))
        
        anim2 = Animation('../resources/tiles/tile_arrow_anim.png', pygame.Rect(0, 0, 32, 32), 3, 0, 0, None, True)
        self._animations['bounce'] = anim2
        self._drawOffsets[anim2] = Vector((0, 0))

        self._sounds['bounce'] = Sound('../resources/sounds/boing.ogg', Constants.GameConstants.SOUND_VOLUME)
        
        self.PlayAnimation('up')
        """
        respawnTuple = StringConversions.StringToIntTuple(self.properties['respawn'])
        
        if self.properties.has_key('unit') and self.properties['unit'] == 'pixel':
            # respawnPos is pixels, so keep it
            self._respawnPos = respawnTuple 
        else:
            # convert from tile coords to pixels
            # this is kinda ghetto
            self._respawnPos = (respawnTuple[0] * self.Width, respawnTuple[1] * self.Height)
                
        
        if self.properties.has_key('facing') and self.properties['facing'] == 'right':
            self._respawnRight = True
        else:
            self._respawnRight = False 
Пример #4
0
 def __init__(self, loaderTile, surface, xIndex, yIndex, layer):
     '''
     Constructor
     '''
     
     GameTile.__init__(self, loaderTile, surface, xIndex, yIndex, layer)