Ejemplo n.º 1
0
 def scaleImage(self, scale):
     self.adjWRad = Tile.ADJ_WIDTH * scale * .5
     self.adjHRad = Tile.ADJ_HEIGHT * scale * .5
     self.adjWidth = int(round(common.x(self.position) + self.adjWRad)) - \
             int(round(common.x(self.position) - self.adjWRad)) + 1
     self.adjHeight = int(round(common.y(self.position) + self.adjHRad)) - \
             int(round(common.y(self.position) - self.adjHRad)) + 1
     self.scaledImage  = pygame.transform.smoothscale(self.image,
         (self.adjWidth, self.adjHeight))
Ejemplo n.º 2
0
def getAreasToCheck(location, grid, gridRes):
    row = int(common.y(location) // gridRes) + 1
    col = int(common.x(location) // gridRes) + 1
    areasToCheck = []
    for i in range(-1, 1 + 1):
        for j in range(-1, 1 + 1):
            if (row + i >= 0 and col + j >= 0 and row + i < len(grid) and
                    col + j < len(grid[0])):
                areasToCheck.append(grid[row + i][col + j])
    return areasToCheck
Ejemplo n.º 3
0
def toGrid(myCanvas, myObject, grid, resolution):
    row = int(common.y(myObject.getPosition()) // resolution) + 1
    col = int(common.x(myObject.getPosition()) // resolution) + 1
    if not (row == myObject.gridRow and col == myObject.gridCol):
        if myObject.gridRow is not None:
            grid[myObject.gridRow][myObject.gridCol].remove(myObject)
        if myObject.getRect().colliderect(0, 0, myCanvas.WIDTH,
                myCanvas.HEIGHT):
            myObject.gridRow = row
            myObject.gridCol = col
            grid[row][col].append(myObject)
        else:
            myObject.gridRow = myObject.gridCol = None
Ejemplo n.º 4
0
def resizePalletBack(myCanvas):
    lastTile = myCanvas.tilePallet[-1]
    palletBack = pygame.Rect(0, 0, common.x(lastTile.position) +
            lastTile.scaledImage.get_width() / 2,
            lastTile.scaledImage.get_height())
    return palletBack