Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. import sys
  2. import random
  3. import pygame
  4.  
  5. pygame.init()
  6.  
  7. # для закрывания игры
  8. def finish():
  9. pygame.quit()
  10. sys.exit(0)
  11.  
  12. # длина и ширина дисплея
  13. H = 600
  14. W = 600
  15.  
  16. # создание дисплеяimport pygame
  17. display = pygame.display.set_mode
  18. WHITE = (255, 255, 255)
  19. BLACK = (0, 0, 0)
  20. GRAY = (125, 125, 125)
  21. BLUE = (0, 0, 255)
  22. GREEN = (0, 255, 0)
  23. YELLOW = (225, 225, 0)
  24. PINK = (230, 50, 230)
  25. RED = (255, 0, 0)
  26.  
  27. # FPS
  28. FPS = 30
  29. fps_clock = pygame.time.Clock()
  30.  
  31. while True:
  32. for event in pygame.event.get():
  33. if event.type == pygame.QUIT:
  34. finish()
  35.  
  36. if event.type == pygame.MOUSEMOTION:
  37. x, y = event.pos
  38. if event.type == pygame.MOUSEBUTTONDOWN:
  39. if event.buttom == 1:
  40. shot = pygame.Rect(x, y, 1, 1)
  41. if shot.colliderect(targetPosition):
  42. targetPosition.bottom = random.randint(30, 360)
  43. targetPosition.left = random.randint(0, 590)
  44.  
  45. # создаём цвет, а также делаем обновление экрана
  46. display.fill((BLACK))
  47. display.blit(target, targetPosition)
  48. pygame.draw.line(display, (WHITE), (0, y), (640, y))
  49. pygame.draw.line(display, (WHITE), (x, 0), (x, 640))
  50. pygame.display.update()
  51. fps_clock.tick(FPS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement