Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def render(self, surface):
tileImage = self.tmxdata.get_tile_image_by_gid
for layer in self.tmxdata.visible_layers:
if isinstance(layer, pytmx.TiledTileLayer):
for x, y, gid, in layer:
tile = tileImage(gid)
if tile:
surface.blit(tile, (x*self.tmxdata.tilewidth, y*self.tmxdata.tileheight))
for tile_object in self.tmxdata.objects:
if tile_object.type == 'blue_cam':
self.blue_cam_spawn = (tile_object.x, tile_object.y)
if tile_object.type == 'red_cam':
self.red_cam_spawn = (tile_object.x, tile_object.y)
if tile_object.type == 'blue_spawn':
self.blue_spawns.append((int(tile_object.name), tile_object.x, tile_object.y))
if tile_object.type == 'red_spawn':
self.red_spawns.append((int(tile_object.name), tile_object.x, tile_object.y))
elif tile_object.type == 'obstacle':
for i in range(int(tile_object.width/WIDTH)):
def __init__(self, filename):
tm = pytmx.load_pygame(filename, pixelalpha=True)
self.width = tm.width * tm.tilewidth
self.height = tm.height * tm.tileheight
self.tmxdata = tm
self.matrix = [[0 for x in range(tm.width)] for y in range(tm.height)]
self.blue_spawns = []
self.red_spawns = []
def __init__(self, filename):
self.init_buffer([screen.get_width() / 2, screen.get_height() / 2])
tmx_data = pytmx.load_pygame("desert.tmx")
map_data = pyscroll.TiledMapData(tmx_data)
self.map_layer = pyscroll.BufferedRenderer(map_data, self.buffer_size)
f = pygame.font.Font(pygame.font.get_default_font(), 20)
t = ["scroll demo. press escape to quit",
"arrow keys move"]
self.text_overlay = [f.render(i, 1, (180, 180, 0)) for i in t]
self.center = [self.map_layer.width/2,self.map_layer.height/2]
self.camera_vector = [0, 0, 0]
self.running = False
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 test_when_passed_false_it_should_return_false(self):
self.assertFalse(convert_to_bool("false"))
def test_when_passed_no_it_should_return_false(self):
self.assertFalse(convert_to_bool("no"))
def test_when_passed_garbage_it_should_raise_value_error(self):
with self.assertRaises(ValueError):
convert_to_bool("garbage")
def test_when_passed_yes_it_should_return_true(self):
self.assertTrue(convert_to_bool("yes"))
def test_when_passed_None_it_should_raise_value_error(self):
with self.assertRaises(ValueError):
convert_to_bool(None)
def test_when_passed_true_it_should_return_true(self):
self.assertTrue(convert_to_bool("true"))