My game implements a random map generator that creates a map and loads the data into a 2D list. Hooray that works, however I am having difficulty implementing this into my main.py for the game.
Heres what should be done: For every spot in the array that is designated a floor tile, place a floor tile.
Heres the problem: It is creating a new instance of floor tile for every floor tile, therefore causing significant framerate loss when moving around a room.
I was wondering if the same floor tile could be rendered in multiple places without having to load the gpu with the same model hundreds of times. If so, could they also have different tags?
This is what I currently am working with:
map= map = mapGen.mapGen(150).map#this works fine, makes 2d list for i in xrange(len(map)): for j in xrange(len(map[i])): if map[i][j]=='#' or map[i][j]=='-': placeholder = loader.loadModel("Media/world")#this is the tile that will be loaded dont use self placeholder.setPos(2*i, 2*j, 0)#sets the pos of the tile placeholder.setScale(.2) self.environment.append(placeholder)#puts the tile in the list for i in xrange(0,len(self.environment)): self.environment[i].reparentTo(render)#reparents the tile so it will be drawn self.environment[i].setTag('ground',str(i))#sets the tag for the tile, str(i) gives the tag a number used for tracking later