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()
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)