import pygame import math from pygame.locals import * pygame.init() width, height = 680, 450 screen=pygame.display.set_mode((width, height)) pygame.display.set_caption("PING PONG IGRA") xpomeraj, ypomeraj = 30,50 w=20 h=2*(ypomeraj) vel = 7 p1_x, p1_y = xpomeraj, height//2-ypomeraj p2_x, p2_y = width-w-xpomeraj, height//2-ypomeraj cir_x,cir_y = width/2, height/2 radius = 12 LeviIgrac = pygame.Rect(p1_x, p1_y, w,h) DesniIgrac = pygame.Rect(p2_x, p2_y, w,h) clock=pygame.time.Clock() run = True while run: for i in pygame.event.get(): if i.type==pygame.QUIT: run=False screen.fill(1) pygame.draw.rect(screen, (255,255,255), LeviIgrac) pygame.draw.rect(screen, (255,255,255), DesniIgrac) pygame.draw.circle(screen,(255,255,255),(round(cir_x),round(cir_y)),radius) keys=pygame.key.get_pressed() if keys[K_UP] and DesniIgrac.top > vel: DesniIgrac.y = DesniIgrac.y - vel if keys[K_DOWN] and DesniIgrac.bottom < height-vel: DesniIgrac.y = DesniIgrac.y + vel if keys[K_w] and LeviIgrac.top > vel: LeviIgrac.y = LeviIgrac.y - vel if keys[K_s] and LeviIgrac.bottom < height-vel: LeviIgrac.y = LeviIgrac.y + vel clock.tick(50) pygame.display.update() pygame.quit()