Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import random
- import pygame
- pygame.init()
- # для закрывания игры
- def finish():
- pygame.quit()
- sys.exit(0)
- # длина и ширина дисплея
- H = 600
- W = 600
- # создание дисплеяimport pygame
- display = pygame.display.set_mode
- WHITE = (255, 255, 255)
- BLACK = (0, 0, 0)
- GRAY = (125, 125, 125)
- BLUE = (0, 0, 255)
- GREEN = (0, 255, 0)
- YELLOW = (225, 225, 0)
- PINK = (230, 50, 230)
- RED = (255, 0, 0)
- # FPS
- FPS = 30
- fps_clock = pygame.time.Clock()
- while True:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- finish()
- if event.type == pygame.MOUSEMOTION:
- x, y = event.pos
- if event.type == pygame.MOUSEBUTTONDOWN:
- if event.buttom == 1:
- shot = pygame.Rect(x, y, 1, 1)
- if shot.colliderect(targetPosition):
- targetPosition.bottom = random.randint(30, 360)
- targetPosition.left = random.randint(0, 590)
- # создаём цвет, а также делаем обновление экрана
- display.fill((BLACK))
- display.blit(target, targetPosition)
- pygame.draw.line(display, (WHITE), (0, y), (640, y))
- pygame.draw.line(display, (WHITE), (x, 0), (x, 640))
- pygame.display.update()
- fps_clock.tick(FPS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement