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):
tm = load_pygame(filename)
# self.size will be the pixel size of the map
# this value is used later to render the entire map to a pygame surface
self.pixel_size = tm.width * tm.tilewidth, tm.height * tm.tileheight
self.tmx_data = tm
def __init__(self, map_filename, saved_game=None):
pygame.init()
self.screen = pygame.display.set_mode(DISPLAY)
pygame.display.set_caption("Nautili")
self.player = PLAYER1
self.map_filename = map_filename
try:
self.layers_handler = lh = LayersHandler(
load_pygame(os.path.join(MAP_DIR, map_filename + ".tmx"))
)
except Exception as ex:
print "Unable to read map data. Possibly messed up layers."
raise ValueError
# Background
self.bg_surface = pygame.Surface((MAIN_WIN_WIDTH, MAIN_WIN_HEIGHT), pygame.SRCALPHA).convert_alpha()
# Panel
self.right_panel = RightPanel(self,
(MAIN_WIN_WIDTH - RIGHT_PANEL_WIDTH, MINIMAP_HEIGHT),
(RIGHT_PANEL_WIDTH, RIGHT_PANEL_HEIGHT))
self.minimap = MiniMap(self, (MAIN_WIN_WIDTH - MINIMAP_WIDTH, 0), (MINIMAP_WIDTH, MINIMAP_HEIGHT))
self.background = IsometricRenderer(self.layers_handler, self.bg_surface)
# Helper variables from layers handler
self.sea = lh.sea
self.docks = lh.docks
self.highlighted_sea = lh.highlighted_sea
def __init__(self):
self.running = False
self.fog_enabled = False
# load map data
tmx_data = load_pygame(self.filename, pixelalpha=True)
# load and play music if one is defined
if "music" in tmx_data.properties:
music = tmx_data.properties["music"]
pygame.mixer.music.load(get_music(music))
pygame.mixer.music.play(-1)
# use fog of war if it is defined
if "fog" in tmx_data.properties:
if tmx_data.properties["fog"].lower() in ["yes", "true"]:
self.fog_enabled = True
# use starting position if defined in map
if "start" in tmx_data.properties:
starting_position = tmx_data.properties["start"].replace(" ", "").split(",")
starting_position[0] = int(starting_position[0])
def __init__(self):
filename = self.get_map('level.tmx')
# Load data from pyTMX
self.tmx_data = pytmx.load_pygame(filename, pixelalpha=True)
# Create new data source for pyScroll
self.map_data = pyscroll.data.TiledMapData(self.tmx_data)
def __init__(self):
# true while running
self.running = False
# load data from pytmx
tmx_data = load_pygame(self.filename)
# setup level geometry with simple pygame rects, loaded from pytmx
self.walls = list()
for object in tmx_data.objects:
self.walls.append(pygame.Rect(
object.x, object.y,
object.width, object.height))
# create new data source for pyscroll
map_data = pyscroll.data.TiledMapData(tmx_data)
# create new renderer (camera)
self.map_layer = pyscroll.BufferedRenderer(map_data, screen.get_size(), clamp_camera=False, tall_sprites=1)
self.map_layer.zoom = 2
# pyscroll supports layered rendering. our map has 3 'under' layers
def __init__(self):
# true while running
self.running = False
# load data from pytmx
tmx_data = load_pygame(self.filename)
# setup level geometry with simple pygame rects, loaded from pytmx
self.walls = list()
for object in tmx_data.objects:
self.walls.append(pygame.Rect(
object.x, object.y,
object.width, object.height))
# create new data source for pyscroll
map_data = pyscroll.data.TiledMapData(tmx_data)
# create new renderer (camera)
self.map_layer = pyscroll.BufferedRenderer(map_data, screen.get_size())
self.map_layer.zoom = 2
# pyscroll supports layered rendering. our map has 3 'under' layers
'width': 16,
'x': 0,
'y': 0}
"""
# Load the tmx map data using the pytmx library.
self.filename = filename
# Scale the loaded tiles if enabled
if prepare.CONFIG.scaling:
self.data = pytmx.TiledMap(filename,
image_loader=scaled_image_loader,
pixelalpha=True)
self.data.tilewidth, self.data.tileheight = prepare.TILE_SIZE
else:
self.data = load_pygame(filename, pixelalpha=True)
# Get the properties of the map
if type(self.data.properties) == dict:
# Get the edge type of the map
if "edges" in self.data.properties:
self.edges = self.data.properties["edges"]
# make a scrolling renderer
self.renderer = self.initialize_renderer()
# Get the map dimensions
self.size = self.data.width, self.data.height
# Get the tile size of the map
self.tile_size = self.data.tilesets[0].tilewidth, self.data.tilesets[0].tileheight
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