Esempio n. 1
0
    def moveColumn(self, column, direction):
        # this function should probably be replaced once numpy is more
        # prevalent .. or not.

        # don't move the corners
        if column == 0 or column == self.getTotalColumns()-1:
            return False

        self.floating_tile.trackMouse = False

        if direction == NORTH:
            newFloatingTile = self.board[0][column]
            newFloatingTile.setTile(sliding=NORTH)

            for row in range(self.getTotalRows()-1):
                self.board[row][column] = self.board[row+1][column]

            self.animateColumn(self.people, column, NORTH)

            newTile = self.floating_tile
            tile.setItemOnTile(newFloatingTile, newTile)
            newTile.setTile(location=(column, self.getTotalRows()),
                sliding=NORTH, realign=True)

            self.board[self.getTotalRows()-1][column] = newTile

        elif direction == SOUTH:
            newFloatingTile = self.board[self.getTotalRows()-1][column]
            newFloatingTile.setTile(sliding=SOUTH)

            # yay for having to make a new copy in mem
            for row in range(1, self.getTotalRows())[::-1]:
                self.board[row][column] = self.board[row-1][column]

            self.animateColumn(self.people, column, SOUTH)

            newTile = self.floating_tile
            tile.setItemOnTile(newFloatingTile, newTile)
            newTile.setTile(location=(column, -1), sliding=SOUTH, realign=1)

            self.board[0][column] = newTile

        else:
            return False

        self.floating_tile = newFloatingTile
        self.lastMove = (column, direction)
        self.updateBoard()
        return True
Esempio n. 2
0
    def moveRow(self, row, direction):
        # don't move the corners
        if row == 0 or row == self.getTotalRows()-1:
            return False

        self.floating_tile.trackMouse = False

        if direction == WEST:
            self.animateRow(self.people, row, direction)

            newFloatingTile = self.board[row][0]
            newFloatingTile.setTile(sliding=WEST)

            self.board[row][0:1] = []

            newTile = self.floating_tile
            tile.setItemOnTile(newFloatingTile, newTile)
            newTile.setTile(location=(self.getTotalColumns(), row),
                            sliding=WEST, realign=True)

            self.board[row].append(newTile)

        elif direction == EAST:
            self.animateRow(self.people, row, direction)

            newFloatingTile = self.board[row][self.getTotalColumns()-1]
            newFloatingTile.setTile(sliding=EAST)
 
            self.board[row] = self.board[row][:-1]

            newTile = self.floating_tile
            tile.setItemOnTile(newFloatingTile, newTile)
            newTile.setTile(location=(-1, row), sliding=EAST, realign=True)

            self.board[row][0:0] = [newTile]

        else:
            return False

        self.floating_tile = newFloatingTile
        self.lastMove = (row, direction)
        self.updateBoard()
        return True