I'm making a game and I've made a click and drag system. The only problem is that when I'm dragging it the object (in my case a circle) it is very laggy like a sideshow, but only the circle lags. Below is the function in the class:
def select_func(self):
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
if click[0] == 1:
if self.posX + self.radius > mouse[0] > self.posX - self.radius and self.posY + self.radius > mouse[1] > self.posY - self.radius and self.select is False:
self.select = True
while self.select:
self.posX = mouse[0]
self.posY = mouse[1]
for squareNum in range (0, 100):
main.square_group.all(squareNum)
squareNum += 1
main.button(main.new_token, "New Token", main.grey, main.light_grey, main.brown, 800, 0, 200, 100, 22)
if click[0] == 1:
self.select = False
pygame.display.update()
main.clock.tick(60)