I have a pygame. in it there are a few nested while loops, running all of them one time accomplish one round, how do I keep rounds going and going, never stop?
Repeat{I have a pygame. in it there are a few nested while loops, running all of them one time accomplish one round, how do I keep rounds going and going, never stop? I have a pygame. in it there are a few nested while loops, running all of them one time accomplish one round, how do I keep rounds going and going, never stop? I have a pygame. in it there are a few nested while loops, running all of them one time accomplish one round, how do I keep rounds going and going, never stop? I have a pygame. in it there are a few nested while loops, running all of them one time accomplish one round, how do I keep rounds going and going, never stop? }Repeat
def running_game():
import pygame
pygame.init()
window = pygame.display.set_mode((640, 480))
robot = pygame.image.load("robot.png")
x = 0
y = 0
velocity = 5
clock = pygame.time.Clock()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
window.fill((0, 0, 0))
window.blit(robot, (x, y))
pygame.display.flip()
print(x)
x += velocity
if x+robot.get_width() >= 640:
#break
#print(x)
while True:
window.fill((0, 0, 0))
window.blit(robot, (x, y))
pygame.display.flip()
y += velocity
#clock.tick(60)
if y+robot.get_height() >= 480:
#break
velocity = -velocity
while True:
window.fill((0, 0, 0))
window.blit(robot, (x, y))
pygame.display.flip()
x += velocity
if x <= 0:
#break
while True:
window.fill((0, 0, 0))
window.blit(robot, (x, y))
pygame.display.flip()
y += velocity
if y <= 0:
velocity = -velocity
break
clock.tick(120)
if __name__ == "__main__":
while True:
running_game()