def rotate_drop(self): s = 1 Board.print_board(self, dot) sounds.play_trap(.1,sounds.octaves(scale,3)[-s]*55) print(margin + Board.purple + '\n' + ' '*9, end = '\r') time.sleep(.2) while(Board.will_drop(self) == 1): for row in self.board: for i in range(len(row) - 1): if row[i] == 0 and row[i+1] != 0: row[i] , row[i+1] = row[i+1], row[i] Board.print_board(self, dot) print(margin + Board.purple + '\n' + ' '*9, end = '\r') s += 1 sounds.play_trap(.1,sounds.octaves(scale,3)[-s]*55) time.sleep(.2) return self
def drop(self, row, mark): for i in range(len(self.board[row])-1,-1,-1): print(margin + ' ') if self.board[row][i] == 0: self.board[row][i] = mark Board.print_board(self, dot) if i == 0 or not self.board[row][i-1] == 0: Board.print_board(self, star) print(margin + Board.purple + '\n' + ' '*9, end = '\r') sounds.play_trap(.3,110*sounds.octaves(scale,3)[i]) time.sleep(0.3) print(margin + ' ') Board.print_board(self, dot) print(margin + '\n', end = '\r') return self print(margin + Board.purple + '\n' + ' '*9, end = '\r') sounds.play_trap(.1,sounds.octaves(scale,3)[i]*110) time.sleep(0.2) self.board[row][i] = 0 return self
def drop(self, row, mark): """ Takes care of dropping a single piece Not sure if this still needs to exist because there is a more general drop function available """ for i in range(len(self.board[row]) - 1, -1, -1): print(margin + ' ') if self.board[row][i] == 0: self.board[row][i] = mark Board.print_board(self, dot) if i == 0 or not self.board[row][i - 1] == 0: print(margin + ' ') Board.print_board(self, star) # i think the print method is to blame for # all these extra empty print lines: # theyre just to bring the cursor down a line # for which i think an ansi escape would work # even better print(margin + Board.purple + '\n' + ' ' * 9, end='\r') sounds.play_trap(.3, 220 * random.choice(scale)) time.sleep(0.3) print(margin + ' ') Board.print_board(self, dot) print(margin + '\n', end='\r') return self print(margin + Board.purple + '\n' + ' ' * 9, end='\r') sounds.play_trap(.1, 220 * random.choice(scale)) time.sleep(0.2) self.board[row][i] = 0 return self