Feb-27-2020, 03:33 AM
I thank you for this. I've been spending some time looking at it. Some of it is unfamiliar to me, but I think this is the real trick, right?
def draw(self, surface, camera, player): x_pos = camera.position.x / self.tilesize y_pos = camera.position.y / self.tilesize x_range = self.get_range(camera.position.x, self.display_size.x, self.map_size[0]) y_range = self.get_range(camera.position.y, self.display_size.y, self.map_size[1]) for x, y in product(x_range, y_range): try: position = int((x - x_pos) * self.tilesize) , int((y - y_pos) * self.tilesize) tile = self.map_data[y][x] if isinstance(tile, TileLayer): tile.draw(surface, position, self.images, player) else: surface.blit(self.images[tile], position) except: passThis is the part that save CPU power, no? It looks to me to be the part that finds and draws only the tiles who's coordinates occur on the screen surface. That's the big difference between how I'm currently doing it.