Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, filename):
# load data from pytmx
tmx_data = load_pygame(filename)
# create new data source
map_data = pyscroll.data.TiledMapData(tmx_data)
# create new renderer
self.map_layer = pyscroll.orthographic.BufferedRenderer(map_data, screen.get_size())
# create a font and pre-render some text to be displayed over the map
f = pygame.font.Font(pygame.font.get_default_font(), 20)
t = ["scroll demo. press escape to quit",
"arrow keys move"]
# save the rendered text
self.text_overlay = [f.render(i, 1, (180, 180, 0)) for i in t]
# set our initial viewpoint in the center of the map
self.center = [self.map_layer.map_rect.width / 2,
self.map_layer.map_rect.height / 2]
# the camera vector is used to handle camera movement
self.camera_acc = [0, 0, 0]
self.camera_vel = [0, 0, 0]