got pygame working now just need to fix this code
okay i managed to get pygame and pycharm working again turns out pygame wasnt in the Interpriter settings even tho it sometimes worked? and that the file kept being changed over to main.py while i was looking at my file got the files back but if anyone know the issues im having that would be great.
please be gentle i only started 2 days ago
import pygame
# pygame setup stuff
pygame.init()
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption('my First Game')
clock = pygame.time.Clock()
running = True
dt = 0
player_pos = pygame.Vector2(screen.get_width() / 2, screen.get_height() / 2)
while running:
# poll for events
# pygame.QUIT () event means the user clicked the X
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# pick the screen color
screen.fill("purple")
# RENDER MY GAME HERE
pygame.draw.circle(screen, "red", player_pos, 40)
# Move the circle
keys = pygame.key.get_pressed()
if keys[pygame.K_UP]:
player_pos.y -= 300 * dt
keys = pygame.key.get_pressed()
if keys[pygame.K_DOWN]:
player_pos.y += 300 * dt
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
player_pos.x -= 300 * dt
keys = pygame.key.get_pressed()
if keys[pygame.K_RIGHT]:
player_pos.x += 300 * dt
# use the mouse!!
if event.type == pygame.MOUSEBUTTONDOWN: (left is were event is getting underlined)
pos = pygame.mouse.get_pos()
#move the circle
player_pos.x = pos[0]
player_pos.y = pos[1]
if event.type == pygame.MOUSEBUTTONDOWN:
pos = pygame.mouse.get_pos()
print(pos)
# Flip the display to output my work to the screen
pygame.display.flip()
# Set the clock stuff / delta time in seconds since the last frame
# Used for framerate independent physics
dt = clock.tick(60) / 1000
pygame.quit()
unresolved reference left: 46
unresolved reference were 46
unexpected expression syntax :46
unexpected index: 47
statement unexpected, found py:DEDENT: 61
name 'event' can be undefined : 46
Posted Jul 5, 2026, 12:29 PM UTC
07