예제 #1
0
 def scalePosition(self, scale):
     self.position = common.myMult(scale, self.absPosition)
     if self.isMovable:
         self.position = common.myAdd(self.position,
                 (self.myCanvas.windowSurface.get_width() / 2,
                  self.myCanvas.windowSurface.get_height() / 2))
     else:
         self.position = common.myAdd(self.position,
                 common.myMult(Canvas.scale, (self.image.get_width() / 2,
                 self.image.get_height() / 2)))
     self.resize(scale)
예제 #2
0
def snapTiles(selectedTile, snapdSide, adjSide):
    snapdTile = snapdSide.tile
    for tile in selectedTile.tileGroup:
        tile.groupOffset = common.mySub(tile.absPosition,
                snapdTile.absPosition)
    for tile in selectedTile.tileGroup:
        tile.matchCorner(snapdSide.corner,
                common.myAdd(adjSide.corner.getAbsPosition(),
                tile.groupOffset))
    snapdTile.adjTile = adjSide.tile
    snapdTile.adjTile.adjTile = snapdTile
    isSnapped = True
    return isSnapped, snapdTile, snapdSide
예제 #3
0
def moveUnSnappable(myCanvas, mouseLoc, selectedTiles, selectedTile, isSnapped,
        sidesToSnap, snapdTile, tiles):
    # Checks each side of one of the tiles which is snapped but can
    # potentially still be unsnapped.  If the distance between this
    # tile and another tile is enough, the tiles unsnap
    for side in snapdTile.sides:
        if (side.adjSide is not None and common.getDistance(common.myAdd(
                common.mySub(mouseLoc, snapdTile.mouseOffset),
                side.corner.getOffset()), side.adjSide.corner.getPosition()) >
                objects.Canvas.SNAP_DISTANCE * objects.Canvas.scale + 1):
            isSnapped, sidesToSnap, snapdTile = moveUnSnap(myCanvas, mouseLoc,
                    selectedTiles, selectedTile, sidesToSnap, tiles)
            break
    return (isSnapped, sidesToSnap, snapdTile)
예제 #4
0
 def getAbsPosition(self):
     return map(int, map(round, common.myAdd(self.tile.absPosition,
             self.offset)))