I was creating my Cuphead inspired game, a fan game and I was creating the warning text and it is lagging a lot like 0-2 fps if anyone can help me I would be very grateful, I don't know if programming on the cell phone interferes with anything or it's the same thing but anyway if you can help me thank you
My code:
import pygame
import sys
pygame.init()
resolutions = ['1152, 648', '1280, 720', '1365, 768', '1600, 900', '1920, 1080']
screen_max = ((1920, 1080))
screen = pygame.display.set_mode((screen_max), pygame.FULLSCREEN | pygame.SCALED)
game_fontT = int(screen_max[0]/30)
game_font = pygame.font.Font('Fonts/AlegreyaSansSC-Bold.ttf', int(game_fontT))
FPS = 60
click = False
linguas = ['espanhol', 'ingles', 'portugues']
lingua = linguas[2]
Warn_Screen = True
def show_fps():
fr = str(int(clock.get_fps()))
frt = game_font.render(str(fr), 1, pygame.Color("coral"))
return frt
def text(text, posx, posy, R, G, B):
posx = int(posx)
posy = int(posy)
R = int(R)
G = int(G)
B = int(B)
score_surface = game_font.render(f'{text}', True, (R, G, B))
score_rect = score_surface.get_rect(center = (posx, posy))
rgb_surface1 = game_font.render(f'{text}', True, (0, 255, 0))
rgb_rect1 = score_surface.get_rect(center = (posx-1, posy-1))
rgb_surface2 = game_font.render(f'{text}', True, (255, 0, 0))
rgb_rect2 = score_surface.get_rect(center = (posx+1, posy+1))
screen.blit(rgb_surface1, rgb_rect1)
screen.blit(rgb_surface2, rgb_rect2)
screen.blit(score_surface, score_rect)
clock = pygame.time.Clock()
while True:
screen.fill([255, 207, 17])
ftr = show_fps()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
click = True
if event.type == pygame.MOUSEBUTTONUP:
click = False
if Warn_Screen:
if lingua == linguas[2]:
text('aviso', screen_max[0]/2, 45, 0, 0, 0)
text(f'Todas as coisas desse jogo pertencem ao studio MDHR', screen_max[0]/2, screen_max[1]/2-310, 0, 0, 0)
text('Tudo que você está jogando aqui é apenas uma recriação', screen_max[0]/2, screen_max[1]/2-260, 0, 0, 0)
text('Todas as músicas, sprites, efeitos, fontes pertencem ao Studio MDHR', screen_max[0]/2, screen_max[1]/2-210, 0, 0, 0)
text('Essa é apenas uma recriação feita por um fã', screen_max[0]/2, screen_max[1]/2-160, 0, 0, 0)
text('Então quando puder compre o original', screen_max[0]/2, screen_max[1]/2-110, 0, 0, 0)
text('Você não irá se arrepender.', screen_max[0]/2, screen_max[1]/2-60, 0, 0, 0)
if lingua == linguas[0]:
text('Advertencia', screen_max[0]/2, 45, 0, 0, 0)
text('Todo el material de este juego pertenece al estudio MDHR', screen_max[0]/2, screen_max[1]/2-310, 0, 0, 0)
text('Todo lo que estás jugando aquí es solo una recreación', screen_max[0]/2, screen_max[1]/2-260, 0, 0, 0)
text('Todas las canciones, sprites, efectos, fuentes pertenecen a MDHR', screen_max[0]/2, screen_max[1]/2-210, 0, 0, 0)
text('Esta es solo una recreación hecha por fanáticos', screen_max[0]/2, screen_max[1]/2-160, 0, 0, 0)
text('Así que cuando puedas comprar el original', screen_max[0]/2, screen_max[1]/2-110, 0, 0, 0)
text('No te arrepentirás.', screen_max[0]/2, screen_max[1]/2-60, 0, 0, 0)
if lingua == linguas[1]:
text('Warning', screen_max[0]/2, 45, 0, 0, 0)
text('All stuff in this game belongs to MDHR studio', screen_max[0]/2, screen_max[1]/2-310, 0, 0, 0)
text("Everything you're playing here is just a recreation", screen_max[0]/2, screen_max[1]/2-260, 0, 0, 0)
text('All songs, sprites, effects, fonts belong to Studio MDHR', screen_max[0]/2, screen_max[1]/2-210, 0, 0, 0)
text('This is just a fan-made recreation', screen_max[0]/2, screen_max[1]/2-160, 0, 0, 0)
text('So when you can buy the original', screen_max[0]/2, screen_max[1]/2-110, 0, 0, 0)
text('You will not regret.', screen_max[0]/2, screen_max[1]/2-60, 0, 0, 0)
if click:
Warn_Screen = False
screen.blit(ftr, (0, 0))
pygame.display.flip()
clock.tick(FPS)