#!/bin/python
import pygame, sys
import random
import math
WHITE = (255, 255, 255)
pygame.init()
sc = pygame.display.set_mode((500, 500))
pygame.display.set_caption("Лапа на pygame")
clock = pygame.time.Clock()
pygame.time.set_timer(pygame.USEREVENT, 1000)
sc.fill((125,125,125))
x1 = random.randint(50,500)
y1 = random.randint(50,500)
x2 = random.randint(50,500)
y2 = random.randint(50,500)
state = 0
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.USEREVENT:
state = state + 1
if state == 1:
x1 = random.randint(50,500)
y1 = random.randint(50,500)
pygame.draw.line(sc, WHITE, [x1, y1], [x2, y2], 3)
if state == 2:
x2 = random.randint(50,500)
y2 = random.randint(50,500)
pygame.draw.line(sc, WHITE, [x2, y2], [x1, y1], 3)
state = 0
pygame.display.flip()
|