Можно добавить условие и запретить выход примитива за границы экрана:
import sys
import pygame
pygame.init()
SIZE = WIDTH, HEIGHT = 800, 600
screen = pygame.display.set_mode(SIZE)
clock = pygame.time.Clock()
x, y = 350, 250
while 1:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
    if x < WIDTH - 100:
        x += 1
    screen.fill((0, 0, 0))
    pygame.draw.rect(screen, (255, 255, 255), (x, y, 100, 100), 5)
    pygame.display.update()
    clock.tick(30)