I was trying to make a function that drew a rectangular map onto the screen. This function is:
def parseMap(mapIndex):
tileRect = pygame.Rect(0, 0, 32, 32)
for x in maps.mapData[mapIndex]:
tileRect.x = x*16
for y in x:
tileRect.y = y*16
c.blit(maps.grass, tileRect)
if maps.mapData[mapIndex][x][y] == 1: c.blit(maps.tallGrass, tileRect)
Though, I was getting an error,
TypeError: invalid rect assignment
on the line:
tileRect.x = x*16
and I can't see anything wrong with the code. Thanks!
If x
is a list, then x * 16
does list repetition, not multiplication.
i.e., you're getting something like
tileRect.x = [1, 1, 1, 1, ...]