Pygame при отрисовке тайтлов падает фпс
В главном цикле в main.py вызываю только map.drawMap()
В map1.txt
map->0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1
map.py
import pygame
windowWidth, windowHeight = 1440,800
class Map():
def __init__(self,mapName):
self.map = []
self.objects = []
self.npc = []
self.tileList = []
self.tileScale = 5
self.readMap(mapName)
def readMap(self, mapName):
mapa = []
f = open('.\\maps\\map1.txt')
for line in f:
line = line.replace("\n","")
if (line.split("->"))[0]=="map":
mapa = (line.split("->"))[1].split(",")
elif (line.split("->"))[0]=="npc":
self.npc.append(list(((line.split("->"))[1]).split(",")))
elif (line.split("->"))[0]=="obj":
self.objects.append(list(((line.split("->"))[1]).split(",")))
f.close()
self.map = list(mapa)
self.initMap()
def initMap(self):
g = 0
for c in range(len(self.map)):
if self.map[c] == "0":
self.tileList.append(Tile(".\\resources\\tiles\\sky.png",g*32*self.tileScale,c//9*32*self.tileScale,self.tileScale))
elif self.map[c] == "1":
self.tileList.append(Tile(".\\resources\\tiles\\tile1.png",g*32*self.tileScale,c//9*32*self.tileScale,self.tileScale))
g += 1
if g==9:
g=0
def drawMap(self,gameWindow):
#print(self.tileList)
for c in range(len(self.tileList)):
self.tileList[c].drawTile(gameWindow)
class Tile():
def __init__(self,tileFileName,x,y,tileScale):
self.tileScale = tileScale
self.image = pygame.transform.scale(pygame.image.load(tileFileName),(32*self.tileScale,32*self.tileScale))
self.rect = self.image.get_rect()
self.rect.x = x
self.rect.y = y
self.x = x
self.y = y
def drawTile(self,gameWindow):
gameWindow.blit(self.image,(self.rect.x,self.rect.y))
def __del__(self):
del self
При отрисовке 3-4 тайтлов еще норм, но с каждым разом все сильнее лагает. Пробовал отрисовывать одну большую картинку, но тоже не помогает