The problem is that you are drawing your background only once. This means that your paddle, as it moves, leaves behind the pixels it has turned white without anything to cover them up. To solve this, fill your background with black and redraw your center line with each iteration of the while loop.
Here is the corrected code:
import pygame, sys, random
from pygame.locals import *
pygame.init()
gamename = pygame.display.set_caption('Pong')
clock = pygame.time.Clock()
FPS = 60
black = (0, 0, 0)
white = (255, 255, 255)
screen = pygame.display.set_mode((800, 800))
screen.fill(black)
pygame.draw.line(screen, white, (400, 800), (400, 0), 5)
#You don't need to set this to a variable, it's just a command
class Player(object):
def __init__(self, screen):
pady = 350
padx = 40
padh = 100
padw = 35
dist = 5
self.pady = pady
self.padx = padx
self.padh = padh
self.padw = padw
self.dist = dist
self.screen = screen
def draw(self):
playerpaddle = pygame.rect.Rect((self.padx, self.pady, self.padw, self.padh))
pygame.draw.rect(self.screen, white, playerpaddle)
def controlkeys(self):
key = pygame.key.get_pressed()
if key[pygame.K_s]:
self.pady += self.dist
elif key[pygame.K_w]:
self.pady -= self.dist
pygame.display.update()
player = Player(screen)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
player.controlkeys()
screen.fill(black)#Covers up everything with black
pygame.draw.line(screen, white, (400, 800), (400, 0), 5)#Redraws your line
player.draw()
pygame.display.update()
clock.tick(FPS)