Advertisement
cookertron

Labros Zabi - Checker Board

Mar 30th, 2022
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. import pygame
  2.  
  3. WHITE = (255, 255, 255)
  4. BLACK = (0, 0, 0)
  5.  
  6. pygame.init()
  7. PDR = pygame.Rect(0, 0, 600, 600)
  8. PDS = pygame.display.set_mode(PDR.size)
  9. FONT = pygame.font.SysFont("arial", 20)
  10.  
  11. # create a checker board
  12. checker = pygame.Surface((512, 512))
  13. for pos in range(64):
  14.     pygame.draw.rect(checker, WHITE if (pos + pos // 8 % 2) % 2 else BLACK, (pos % 8 * 64, pos // 8 * 64, 64, 64))
  15. PDS.blit(checker, (44, 44))
  16.  
  17. # display letters and numbers
  18. for pos in range(8):
  19.     a = FONT.render("ABCDEFGH"[pos], False, WHITE)
  20.     b = FONT.render(str(pos + 1), False, WHITE)
  21.     PDS.blit(a, (-a.get_rect().w // 2 + 76 + pos * 64, -a.get_rect().h // 2 + 578))
  22.     PDS.blit(b, (-a.get_rect().h // 2 + 22, -a.get_rect().w // 2 + 76 + pos * 64))
  23.  
  24. pygame.display.update()
  25.  
  26. exit_demo = False
  27. while not exit_demo:
  28.     for e in pygame.event.get():
  29.         if e.type == pygame.KEYUP:
  30.             if e.key == pygame.K_ESCAPE: exit_demo = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement