(move, screen,board, clock)
| 126 | screen.blit(IMAGES[piece], p.Rect(c*SQ_SIZE, r*SQ_SIZE, SQ_SIZE, SQ_SIZE)) |
| 127 | |
| 128 | def animatedMoves(move, screen,board, clock): |
| 129 | global colors |
| 130 | dR = move.endRow - move.startRow |
| 131 | dC = move.endCol - move.startCol |
| 132 | framesPerSquare = 5 |
| 133 | frameCount = (abs(dR) + abs(dC)) * framesPerSquare |
| 134 | for frame in range(frameCount + 1): |
| 135 | r,c =((move.startRow + dR*frame/frameCount, move.startCol + dC*frame/frameCount)) |
| 136 | drawBoard(screen) |
| 137 | drawPieces(screen, board) |
| 138 | color = colors[(move.endRow + move.endCol)%2] |
| 139 | endSquare = p.Rect(move.endCol*SQ_SIZE, move.endRow*SQ_SIZE, SQ_SIZE, SQ_SIZE) |
| 140 | p.draw.rect(screen, color, endSquare) |
| 141 | if move.pieceCaptured != "--": |
| 142 | screen.blit(IMAGES[move.pieceCaptured], endSquare) |
| 143 | |
| 144 | screen.blit(IMAGES[move.pieceMoved], p.Rect(c*SQ_SIZE, r*SQ_SIZE, SQ_SIZE, SQ_SIZE)) |
| 145 | p.display.flip() |
| 146 | clock.tick(60) |
| 147 | |
| 148 | def drawText(screen, text): |
| 149 | font = p.font.SysFont("Helvitca", 32, True, False) |
no test coverage detected