while 1:
for event in pygame.event.get():
if event.type == pygame.quit():
sys.exit()
position = position.move(speed)
if position.left < 0 or position.right > width:
role = pygame.transform.flip(role, True, False)
speed[0] = -speed[0]
if position.top < 0 or position.bottom > height:
speed[1] = -speed[1]
screen.fill(bg)
screen.blit(role, position)
pygame.display.flip()
pygame.time.delay(10)