Feb-27-2020, 11:25 AM
Yes. Just looks up what in screen area. All the rest is ignore. But need to remove try and except. That was for something I was testing. Forgot to remove it.
Example just for background or foreground.
Example just for background or foreground.
def draw(self, surface, camera): location = camera.position / self.tilesize x_range = self.get_range(camera.position.x, self.display_size.x, self.mapsize[0]) y_range = self.get_range(camera.position.y, self.display_size.y, self.mapsize[1]) for x, y in product(x_range, y_range): position = int((x - location.x) * self.tilesize), int((y - location.y) * self.tilesize) tile = self.map_data[y][x] if tile: surface.blit(self.map_images[tile], position) def get_range(self, start_position, end_position, max_position): start = start_position / self.tilesize start_range = max(int(start), 0) end_range = min(int(start + end_position), max_position) return range(start_range, end_range)
99 percent of computer problems exists between chair and keyboard.