I've been making game using pygame and found out necessity of new window in this game. screenshot of the game
When boy collide with one of the companies(Web Canape, Smolenskiye Brillianty...) new window must be opened to do quize there. The main game also need to continue working, because boy's task is to go through all companies.
Can someone help me with solving this problem, please?
Probably, it is possible to use new module such as PyQt5 or Tkinter in order not to terminate whole game.
https://github.com/TotumRevolutum/shadows-game
import sys
from map import *
import pygame.display
pygame.init()
WIDTH = 11 * 100
HEIGHT = 7 * 100
clock = pygame.time.Clock()
def text_show(number):
intro_text_1 = ["Привет! Меня зовут Емеля.", "Я приглашаю тебя на День",
"Теней на предприятия", "Смоленской области.", " ", " ДАЛЕЕ"]
intro_text_2 = ['"День Теней" - это день,', "в течение которого школьники",
"могут лично следить за работой ", "специалистов с целью проверки",
"правильности выбора профессии.", " ДАЛЕЕ"]
intro_text_3 = ['Мы с тобой будем определяться', "с профессией по принципу ",
'индукции от "частного" к "общему",', 'от "предприятия" к "профессии."',
"", " ДАЛЕЕ"]
intro_text_4 = ['В конце Дня Теней', "ты сможешь выбрать предприятие,",
'на котором хотел бы работать!', '',
"", " ДАЛЕЕ"]
if number == 1:
text = intro_text_1
elif number == 2:
text = intro_text_2
elif number == 3:
text = intro_text_3
else:
text = intro_text_4
back = Background('bg/boy_start.png', [0, 0])
screen.blit(back.image, back.rect)
font = pygame.font.SysFont("Typewriter", 33)
tmp = 0
for line in text:
if line == " ДАЛЕЕ":
lines = font.render(line, 1, pygame.Color('red'))
else:
lines = font.render(line, 1, pygame.Color('black'))
display_rect = lines.get_rect()
tmp += 10
display_rect.y = 140 + tmp
display_rect.x = 640
tmp += display_rect.height
screen.blit(lines, display_rect)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
elif event.type == pygame.MOUSEBUTTONDOWN:
return
pygame.display.flip()
clock.tick(30)
text_show(1)
text_show(2)
text_show(3)
text_show(4)
running = True
generate_level(load_level())
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
keys = pygame.key.get_pressed()
move_boy(keys, player_group)
all_sprites.draw(screen)
tiles_group.draw(screen)
player_group.draw(screen)
pygame.display.flip()
clock.tick(60)
# other parts are located in the git
# https://github.com/TotumRevolutum/shadows-game