I have been struggling for the past few hours on what I should do, and finally decided to resort to asking on StackOverflow.
PROBLEM: I keep getting terminal traceback calls but I have no idea what I should do about them. I will admit, it is probably me being stupid and not knowing what is happening, but it was my first time on VSCode and importing stuff. When I googled at first, I couldn’t get any answers.
CODE (I have a second file with dvd-image.png):
import pygame, time
pygame.init()
width, height = 800, 600
dvdLogoSpeed = [1, 1]
backgroundColor = 0, 0, 0
screen = pygame.display.set_mode((width, height))
dvdLogo = pygame.image.load("dvd-image.png")
dvdLogoRect = dvdLogo.get_rect()
while True:
screen.fill(backgroundColor)
screen.blit(dvdLogo, dvdLogoRect)
dvdLogoRect = dvdLogoRect.move(dvdLogoSpeed)
if dvdLogoRect.left < 0 or dvdLogoRect.right > width:
dvdLogoSpeed[0] = -dvdLogoSpeed[0]
if dvdLogoRect.top < 0 or dvdLogoRect.bottom > height:
dvdLogoSpeed[1] = -dvdLogoSpeed[1]
pygame.display.flip()
time.sleep(10 / 1000)
TRACEBACK CALLS:
Traceback (most recent call last): File "/Users/xxx/Desktop/untitled101/pygame.py", line 1, in import pygame File "/Users/xxx/Desktop/untitled101/pygame.py", line 3, in pygame.init() AttributeError: partially initialized module 'pygame' has no attribute 'init' (most likely due to a circular import)
EXTRA INFORMATION:
pygame
is a Python package and you have your own project named "pygame".
Pylance will recognize your project as the pygame package.
You can change your projcet name to solve it.