Exemplo n.º 1
0
def moveAll(myCanvas, mouseLoc, tiles, grid, gridRes, dirtyRects, isDrawAll,
        windowSurface):
    for tile in tiles:
        misc.toGrid(myCanvas, tile, grid, gridRes)
        pygame.draw.rect(windowSurface, objects.Canvas.BACK_COLOR,
                tile.getRect())
        dirtyRects.append(tile.getRect())
        tile.setPosition(common.mySub(mouseLoc, tile.mouseOffset))
        tile.scalePosition(objects.Canvas.scale)
        isDrawAll = True
    return isDrawAll
Exemplo n.º 2
0
def checkUnclick(myCanvas, isUnClick, isClick, tiles, selectedTiles,
        isDrawClicked, oldPositions, dirtyRects, selectedTile, isSnapped,
        sidesToSnap, snapdTile, grid, gridRes, snapdSide):
    # This block only evaluates if the user has unclicked, and not also
    # re-clicked during the update
    if isUnClick and not isClick:
        # This block only evaluates if a tile or group of tiles have
        # been positioned to snap together in a previous update
        if isSnapped:
            # This checks each side from the selected tile group which
            # is to be snapped to another tile.  It then checks whether
            # or not the tile it is to be snapped to is already a part
            # of its tile group, and if not, adds each tile in its tile
            # group to the tile group of the tile it is snapping to, and
            # then sets its own tile group to the tile group of the tile
            # it is snapping to.  Basically the two tile groups merge.
            # This is set up to work even if one tile group is
            # connecting simultaniously to two  or more
            # other disconnected tile groups.
            for side in sidesToSnap:
                if side.adjSide.tile not in selectedTile.tileGroup:
                    for tile in selectedTile.tileGroup:
                        side.adjSide.tile.tileGroup.append(tile)
                        tile.tileGroup = side.adjSide.tile.tileGroup
                side.isSnapped = side.adjSide.isSnapped = True
        if selectedTile is not None:
            isDrawClicked = True
            for tile in selectedTiles:
                oldPositions.append(tile.position)
                misc.toGrid(myCanvas, tile, grid, gridRes)
        isSnapped = False
        snapdSide = None
        ajdSide = None
        snapdTile = None
        sidesToSnap = []
    return (isDrawClicked, selectedTile, isSnapped, sidesToSnap, snapdTile,
            snapdSide)