I would like to draw a white circle moving naturally on the screen, but I get lots of white circles drawn in a discontinuous way without giving the illusion of movement. How can I modify this code?
import pygame
from sys import exit
import math
BLACK = [0, 0, 0]
WHITE = [255, 255, 255]
class Game():
def __init__(self):
pygame.init()
self.window = pygame.display.set_mode((500, 500), 0, 32)
pygame.display.set_caption('Jumping ball')
self.clock = pygame.time.Clock()
def mainloop(self):
while True:
EVENTS = pygame.event.get()
for event in EVENTS:
if event.type == pygame.QUIT:
exit()
time = self.clock.tick(60) # [seconds]
x, y = 100 + 50 * math.sin(time), 100 + 50 * math.cos(time)
x, y = int(x), int(y)
radius = 5
pygame.draw.circle(self.window, WHITE, (x, y), radius)
#self.screen.blit(ball, (x, y))
pygame.display.update()
if __name__ == '__main__':
game = Game()
game.mainloop()