I have currently a pygame program that stores tiles in a 2d list like
[[1,1,1] [1,1,1] [1,1,1]]
where the 1 is a tile object. I have the character centered in the middle of the screen, and I am trying to find the best way to make it so the 'camera' scrolls along with the character. I suppose I could have it so that it only draws the tiles that are in the current window range, but I feel like this will cause problems later. My goal is to have the an entire map, say 100x100 tiles that are drawn but only a small section is shown. So the enemies I generate would still be walking around the map, and things would be going normally except I can only see a small part of it. Is there a way I can take advantage of surfaces in pygame to do this more effectively?
Some relevant code.
def drawMap(self, screen): for y in range(self.height): for x in range(self.width): self._mapData[y][x].draw(screen, x*48,y*48)
This is in the TileMap class and each index is a Tile object, which has a draw method. My initial idea was to change both the range() calls to draw only the area of the map I want to but then I don't know how to account for enemies off the screen because they are defined by their x and y location relative to the TileMap I create.
I am thinking there is maybe something I can do with a larger pygame surface object that I do not realize so I figured I would ask this here.