0

I’m creating a pygame game on replit. For some reason, I’m not able to put a custom icon. This is my code

# import modules & libraries
import pygame
import random
import time
import sys
import os

# initialize pygame and pygame mixer (music)
pygame.init()
pygame.mixer.init()

# create screenvars
class screenvar:
    HEIGHT = 265
    WIDTH = 390
    CAPTION = "Gam"
    ICON = pygame.image.load("img/icon.png")

# create the screen
displaysurface = pygame.display.set_mode((screenvar.WIDTH, screenvar.HEIGHT))
pygame.display.set_caption(screenvar.CAPTION)
pygame.display.set_icon(screenvar.ICON)

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()

console

Edit: I’m also adding music but for some reasons, it doesn’t work (again)

Code:


# add the music
pygame.mixer.music.load("song.wav")
pygame.mixer.music.set_volume(0.7)
pygame.mixer.music.play(-1)

console

morhexa
  • 3
  • 4
  • 1
    Please read [Discourage screenshots of code and/or errors](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). Do not post a screenshot of the error message. Paste the error message. – Rabbid76 Oct 05 '21 at 20:46
  • Is the _"icon.png"_ file in the _"img"_ folder? – Rabbid76 Oct 05 '21 at 20:48
  • The error pretty much speaks for itself: `No such file or directory`. The file doesn't exist, or is placed in another folder. – D_00 Oct 07 '21 at 06:58

0 Answers0