Advertisement
Korotkodul

snake_v1

Dec 4th, 2023
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. import pygame
  2.  
  3. SIZE_BLOCK = []
  4. WHITE = (255, 255, 255)
  5. BLUE = (204, 255, 255)
  6. FRAME_COLOR = (0, 255, 204)
  7. COUNT_BLOCKS = 20
  8.  
  9. size = [400, 600]
  10. MARGIN = 1
  11. SIZE_BLOCK = 20
  12. screen = pygame.display.set_mode(size)
  13. pygame.display.set_caption('Змейка')
  14.  
  15. while True:
  16.     for event in pygame.event.get():
  17.         if event.type == pygame.QUIT:
  18.             print('exit')
  19.             pygame.quit()
  20.  
  21.     screen.fill(FRAME_COLOR)
  22.  
  23.     for row in range(COUNT_BLOCKS):
  24.         for column in range(COUNT_BLOCKS):
  25.             if (column + row) % 2 == 0:
  26.                 color = BLUE
  27.             else:
  28.                 color = WHITE
  29.             pygame.draw.rect(screen, color, [10 + column * SIZE_BLOCK + MARGIN * (column + 1),
  30.                                              20 + row * SIZE_BLOCK + MARGIN * (row + 1), SIZE_BLOCK, SIZE_BLOCK])
  31.  
  32.     pygame.display.flip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement