im learning pygame and im getting the error
File "c:/Users/fester/Documents/pythonProjects/2021/penisRacingGame/main.py", line 20, in <module>
penisimage = pygame.image.load("pythonProjects\2021\penisRacingGame\car.jpg")
pygame.error: Couldn't open pythonProjects1\penisRacingGame\car.jpg
the image is in the same directory as the code, theres no reason i would even need to specify the directory in my code, i only did because i used the code
print(os.getcwd())
to see where its looking, and it said it was looking in pythonProjects, and not penisRacingGame. But even then it still gives me the error. any help?
code:
import pygame
import os
print(os.getcwd())
pygame.init()
display_width = 800
display_height = 600
black = (0,0,0)
white = (255,255,255)
red = (255,0,0)
gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption('i will steal your toes, no exeptions')
clock = pygame.time.Clock()
penisimage = pygame.image.load("pythonProjects\2021\penisRacingGame\car.jpg")
def penismove(x,y):
gameDisplay.blit(penisimage,(x,y))
x = (display_width * 0.45)
y = (display_height * 0.8)
crashed = False
while not crashed:
for event in pygame.event.get():
if event.type == pygame.QUIT:
crashed = True
gameDisplay.fill(white)
penismove(x,y)
pygame.display.update()
clock.tick(60)
pygame.quit()
quit()
code after pathing down to .\pythonProjects\ and making the file name a raw string:
import pygame
import os
print(os.getcwd())
pygame.init()
display_width = 800
display_height = 600
black = (0,0,0)
white = (255,255,255)
red = (255,0,0)
gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption('i will steal your toes, no exeptions')
clock = pygame.time.Clock()
penisimage = pygame.image.load(r".\pythonProjects\2021\penisRacingGame\car.jpg")
def penismove(x,y):
gameDisplay.blit(penisimage,(x,y))
x = (display_width * 0.45)
y = (display_height * 0.8)
crashed = False
while not crashed:
for event in pygame.event.get():
if event.type == pygame.QUIT:
crashed = True
gameDisplay.fill(white)
penismove(x,y)
pygame.display.update()
clock.tick(60)
pygame.quit()
quit()