0

I am writing a code to transition from one picture to another using button click using pygame. The issues are that I am making the display responsive. So when I successfully transition from one picture to another, the second picture does not completely fill up the screen.

Here is the code for it:

import pygame,sys
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((1920,1024),HWSURFACE|DOUBLEBUF|RESIZABLE)


intro_background = pygame.image.load('assets/background_images/Intro.png')
intro_background_clicked = pygame.image.load('assets/background_images/Intro_click.png')

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
        if event.type == VIDEORESIZE:
            screen = pygame.display.set_mode(event.dict['size'],HWSURFACE|DOUBLEBUF|RESIZABLE)
            screen.blit(pygame.transform.scale(intro_background,event.dict['size']),(0,0))
        if event.type == pygame.MOUSEBUTTONDOWN:
            screen.blit(intro_background_clicked,(0,0))
        ##video resizing

    pygame.display.update()

However, I tried to add the code for resizing on pygame.MOUSEBUTTONDOWN: as given below:

if event.type == pygame.MOUSEBUTTONDOWN:
   screen = pygame.display.set_mode(event.dict['size'],HWSURFACE|DOUBLEBUF|RESIZABLE)
   screen.blit(pygame.transform.scale(intro_background_clicked,event.dict['size']),(0,0))

The error after adding the code is given below:

screen = pygame.display.set_mode(event.dict['size'],HWSURFACE|DOUBLEBUF|RESIZABLE)
KeyError: 'size'

Any help will be greatly appreciated.

0 Answers0