this code when run changes the screen but changes to the original one when i release my mouse why does this happen?when i comment out the screen.blit(bg,(0,0))
and when i click it it works and changes to the other screen normally here is the code to show the problem:
import pygame
import os
game = False
pygame.init()
screen = pygame.display.set_mode((3840, 2160))
running = True
os.chdir(r"C:\Users\tomarj\OneDrive - Tata Advanced Systems Limited\Desktop\War Crime")
pygame.display.set_caption("GermanBall")
bg = pygame.image.load("Tan.jpg")
icon = pygame.image.load("box.png")
button1 = pygame.image.load("shirt.png").convert_alpha()
bg_new = pygame.image.load("big.jpg")
pygame.display.set_icon(icon)
class Button():
def __init__(self, x, y, image, scale):
width = image.get_width()
height = image.get_height()
self.image = pygame.transform.scale(image, (int(width * scale), int(height * scale)))
self.rect = self.image.get_rect()
self.rect.topleft = (x, y)
def draw(self):
screen.blit(self.image, (self.rect.x, self.rect.y))
stat = Button(1550, 700, button1, 0.5)
while running:
pos = pygame.mouse.get_pos()
if stat.rect.collidepoint(pos):
if pygame.mouse.get_pressed()[0] == 1:
game = True
if game:
new_screen = pygame.display.set_mode((3840, 2160))
new_screen.blit(bg_new, (0, 0))
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
screen.blit(bg, (0, 0))
stat.draw()
pygame.display.update()
pygame.quit()