I have a ball animation and I want it so that it that runs until you CLOSE the program (A.K.A until pygame.QUIT is activated) And then after pygame.QUIT is activated it will count down from 10 seconds before it closes.
(PS. If you're an admin of this website the other post you send me doesn't help with my specific problem)
import pygame
import random
pygame.init()
window = pygame.display.set_mode([400,400])
c = pygame.time.Clock()
black = (0,0,0)
white = (255,255,255)
x = random.randint(10,390)
y = random.randint(10,390)
speed_x = random.randint(3,5)
speed_y = random.randint(3,5)
time = 10
#this is definitely wrong so this where I need help on
playing = True
while playing:
for event in pygame.event.get():
if event.type == pygame.QUIT:
time -= 1
print(time)
pygame.time.wait(1000)
time -= 1
print(time)
pygame.time.wait(1000)
time -= 1
print(time)
pygame.time.wait(1000)
time -= 1
print(time)
pygame.time.wait(1000)
time -= 1
print(time)
pygame.time.wait(1000)
time -= 1
print(time)
pygame.time.wait(1000)
time -= 1
print(time)
pygame.time.wait(1000)
time -= 1
print(time)
pygame.time.wait(1000)
time -= 1
print(time)
pygame.time.wait(1000)
time -= 1
print(time)
pygame.time.wait(1000)
if time == 0:
playing = False
x += speed_x
y += speed_y
window.fill((white))
pygame.draw.circle(window,black,(x,y),20)
if x > 390 or x < 10:
speed_x = speed_x * -1
if y > 390 or y < 10:
speed_y = speed_y * -1
c.tick(60)
pygame.display.flip()