I'm new to programming, and this error keeps popping up no matter what. I tried changing the file to something else, or moving all the things altogether. They are in the same folder. Here's the code:
import pygame
import os
import time
import random
pygame.font.init()
pygame.init()
WIDTH, HEIGHT = 750, 750
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Space Shooter Tutorial")
# Sounds
bulletSound = pygame.mixer.Sound("bullet.wav")
hitSound = pygame.mixer.Sound("hit.wav")
music = pygame.mixer.music.load("music.wav")
pygame.mixer.music.play(-1) # -1 will make the song loop
# Load images
RED_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_red_small.png"))
GREEN_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_green_small.png"))
BLUE_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_blue_small.png"))import pygame
import os
import time
import random
pygame.font.init()
pygame.init()
WIDTH, HEIGHT = 750, 750
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Space Shooter Tutorial")
# Sounds
bulletSound = pygame.mixer.Sound("bullet.wav")
hitSound = pygame.mixer.Sound("hit.wav")
music = pygame.mixer.music.load("music.wav")
pygame.mixer.music.play(-1) # -1 will make the song loop
# Load images
RED_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_red_small.png"))
GREEN_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_green_small.png"))
BLUE_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_blue_small.png"))
The trouble come when I run it, and they say :
Traceback (most recent call last): File "/Users/abhivyaktbhati/Desktop/PYTHON NOW/assets/Draft with sounds.py", line 20, in <module> RED_SPACE_SHIP = pygame.image.load(os.path.join("assets", "pixel_ship_red_small.png")) FileNotFoundError: No such file or directory.
How to fix this? PS. This is on a mac.