# Rendering tiles at a larger size for a detailed look

I'm trying to make my 32-bit tiled map become more "zoomed" in. However, I experience an error that I can't resolve. Firstly, I followed this post on how to render the tiles larger.

This is my code (close to identical to the code in the other post):

class TiledMap:
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

def render(self,surface):
ti = 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 = ti(gid)
tile = pg.transform.scale(tile,(64,64))       <---------- Line that gives Error
if tile:
surface.blit(tile,(x * 64, y * 64))

def make_map(self):
temp_surface = pg.Surface((self.width, self.height))
self.render(temp_surface)
return temp_surface


The error that is produced is:

tile = pg.transform.scale(tile,(64,64))
TypeError: argument 1 must be pygame.Surface, not None


I'm suspecting that some tile that its trying to render simply is empty. I've tried a separate smaller map but the issue persists. Is it the tileset? They've all been processed through the program Tiled where they were initially part of one png. If anyone knows a possible solutions I'll gladly try one. Or any other methods that could make it more zoomed in...

The solution in my case was simple, check if the tile is 'None'. If yes, then pass it, but if not, transform it to a larger size. This is the full code that should be used:

class TiledMap:
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

def render(self,surface):
ti = 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 = ti(gid)
if not tile == None:                     <---- This is the change
tile = pg.transform.scale(tile,(64,64))
if tile:
surface.blit(tile,(x * 64, y * 64))

def make_map(self):
temp_surface = pg.Surface((self.width, self.height))
self.render(temp_surface)
return temp_surface



This solution worked for me. Although, i did notice i have to change the camera class as it still limits itself to the 32-bit size.