[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Bug: Circle tearing with mouse clicks within the window.



Python 3.8.6
Pygame 2.0.0
Xubuntu 20.10
Nvidia 1060 6GB

The following code, when run, causes an issue where the circle starts to tear as it moves across the screen if I click on the active window. Where I click seems to matter also, as the tearing can be adjusted by clicking at various points from top to bottom. I'm not checking for mouse events in the code, but I would imagine their still being tracked.

The tearing continues to happen after I've stopped and ran it again as well. It does go back to normal after a few tries. But the effects seem to stay in memory.

I wasn't sure where to send bugs, the website led me here. I hope this is the right place.

# ----------------------------------------
import pygame as pg

# init game space
pg.init()

screen = pg.display.set_mode((600, 400))
pg.display.set_caption("Ball Moving")

playerX = 50
playerY = 50
player_Width = 30
player_Height = 30
playerVelocity = 0.5

# Color Constants
BLUE = (0, 0, 255)

# loop
running = True
while running:
    for event in pg.event.get():
        if event.type == pg.QUIT:
            running = False

    # update screen
    keys = pg.key.get_pressed()
    if keys[pg.K_LEFT]:
        playerX -= playerVelocity
    if keys[pg.K_RIGHT]:
        playerX += playerVelocity
    if keys[pg.K_UP]:
        playerY -= playerVelocity
    if keys[pg.K_DOWN]:
        playerY += playerVelocity

    screen.fill(WHITE)
    pg.draw.circle(screen, (BLUE), (playerX, playerY), player_Width, 0)
    pg.display.flip()

pg.display.quit()
pg.quit()