()
| 420 | |
| 421 | |
| 422 | def enterPlayerTile(): |
| 423 | # Draws the text and handles the mouse click events for letting |
| 424 | # the player choose which color they want to be. Returns |
| 425 | # [WHITE_TILE, BLACK_TILE] if the player chooses to be White, |
| 426 | # [BLACK_TILE, WHITE_TILE] if Black. |
| 427 | |
| 428 | # Create the text. |
| 429 | textSurf = FONT.render('Do you want to be white or black?', True, TEXTCOLOR, TEXTBGCOLOR1) |
| 430 | textRect = textSurf.get_rect() |
| 431 | textRect.center = (int(WINDOWWIDTH / 2), int(WINDOWHEIGHT / 2)) |
| 432 | |
| 433 | xSurf = BIGFONT.render('White', True, TEXTCOLOR, TEXTBGCOLOR1) |
| 434 | xRect = xSurf.get_rect() |
| 435 | xRect.center = (int(WINDOWWIDTH / 2) - 60, int(WINDOWHEIGHT / 2) + 40) |
| 436 | |
| 437 | oSurf = BIGFONT.render('Black', True, TEXTCOLOR, TEXTBGCOLOR1) |
| 438 | oRect = oSurf.get_rect() |
| 439 | oRect.center = (int(WINDOWWIDTH / 2) + 60, int(WINDOWHEIGHT / 2) + 40) |
| 440 | |
| 441 | while True: |
| 442 | # Keep looping until the player has clicked on a color. |
| 443 | checkForQuit() |
| 444 | for event in pygame.event.get(): # event handling loop |
| 445 | if event.type == MOUSEBUTTONUP: |
| 446 | mousex, mousey = event.pos |
| 447 | if xRect.collidepoint( (mousex, mousey) ): |
| 448 | return [WHITE_TILE, BLACK_TILE] |
| 449 | elif oRect.collidepoint( (mousex, mousey) ): |
| 450 | return [BLACK_TILE, WHITE_TILE] |
| 451 | |
| 452 | # Draw the screen. |
| 453 | DISPLAYSURF.blit(textSurf, textRect) |
| 454 | DISPLAYSURF.blit(xSurf, xRect) |
| 455 | DISPLAYSURF.blit(oSurf, oRect) |
| 456 | pygame.display.update() |
| 457 | MAINCLOCK.tick(FPS) |
| 458 | |
| 459 | |
| 460 | def makeMove(board, tile, xstart, ystart, realMove=False): |
no test coverage detected