'when I add pygame.init() it automatically removes the icon that I add
so I have just started learning pygame and I wanted to add an Icon .yet for some reason if pygame.init() was not there I can see my icon but if it's written in the code the icon does not appear and instead it gives some sort of a python logo
I use windows 10 and python 3.10 and vs code
here is my code
import pygame
from sys import exit
pygame.init()
screen = pygame.display.set_mode((800,400))
pygame.display.set_caption("pygame_try3")
clock = pygame.time.Clock()
icon_surface=pygame.image.load(r"D:\stuff for pygame\UltimatePygameIntro-main\graphics\Player\player_stand.png")
pygame.display.set_icon(icon_surface)
sky_surface = pygame.image.load(r"D:\stuff for pygame\UltimatePygameIntro-main\graphics\Sky.png") #putting r is important to import the png file
ground_surface=pygame.image.load(r"D:\stuff for pygame\UltimatePygameIntro-main\graphics\ground.png")
text = pygame.font.Font( r"D:\stuff for pygame\UltimatePygameIntro-main\font\Pixeltype.ttf" ,50)
text_surface = text.render("Za game",False,(0,0,0))
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
screen.blit(sky_surface,(0,0))
screen.blit(ground_surface,(0,300))
screen.blit(text_surface,(330,50))
pygame.display.update()
clock.tick(60)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
