Как отобразить текст для изменяемого размера окна?
Кроме того, возможно ли иметь разные фоны для разных обстоятельств?
Например, я хочу, чтобы в разделе «Приветствие игры» было одно фоновое изображение, а в главном меню - другое.
import pygame
from pygame.locals import *
import numpy as np
import matplotlib.pyplot as plt
import argparse
import threading, os, sys, time
pygame.init()
pygame.display.set_caption("AI Battlehip Game")
FPS = pygame.time.Clock()
red_ = (255,0,0)
def background_image_settings(back_end_image):
back_end_image_set = pygame.image.load(back_end_image)
screen = pygame.display.set_mode((1200,700), HWSURFACE|DOUBLEBUF|RESIZABLE)
screen.blit(pygame.transform.scale(back_end_image_set, (1200,700)), (0,0))
pygame.display.flip()
try: #This function is responsible for making the window resizable and creating the background (in my case it is picture)
while True:
pygame.event.pump()
event = pygame.event.wait()
if event.type == QUIT:
pygame.display.quit()
elif event.type == VIDEORESIZE:
screen = pygame.display.set_mode(event.dict['size'], HWSURFACE|DOUBLEBUF|RESIZABLE)
screen.blit(pygame.transform.scale(back_end_image_set,event.dict['size']), (0,0))
pygame.display.flip()
except:
pass
def text_objects(text, font):
textSurface = font.render(text, True, red_check) #This function is responsible for making the text colourful and font. #Have seen it working with TextSurf, TextRect = text_objects(text, largeText)
return textSurface, textSurface.get_rect()
background_image_settings(r'/Users/user1/Desktop/Project work/images/backgroundimage2.jpg')