python - argument 2 to map() must support iteration -
hi i'm making basic raycast engine think nice start minimap problem class map ask mapgrid in constructor , when pass python give me error argument 2 map() must support iteration
this code: main part
import pygame def map(object): def __init__(self,grid,scale): self.grid= grid self.mapwidth= len(grid[0]) #number of map blocks self.mapheight= len(grid) self.minimapscale= scale #how many pixels draw map block self.miniwidth= self.mapwidth * self.minimapscale #size of minimap self.miniheight= self.mapheight * self.minimapscale self.rectgrid= grid y in range(self.mapheight): x in range(self.mapwidth): self.rectgrid[y][x]= pygame.rect(x,y,self.miniwidth,self.miniheight) def blitminimap(): pass
data file
mapgrid= [ [1,1,1,1], [1,0,0,1], [1,0,0,1], [1,1,1,1] ] size = [640, 480]
map class
import pygame def map(object): def __init__(self,grid,scale): self.grid= grid self.mapwidth= len(grid[0]) #number of map blocks self.mapheight= len(grid) self.minimapscale= scale #how many pixels draw map block self.miniwidth= self.mapwidth * self.minimapscale #size of minimap self.miniheight= self.mapheight * self.minimapscale self.rectgrid= grid y in range(self.mapheight): x in range(self.mapwidth): self.rectgrid[y][x]= pygame.rect(x,y,self.miniwidth,self.miniheight) def blitminimap(): pass
thanks.
map
python built-in function. using map
function name leads confusion, should consider renaming map
function different.
also, call "map class" defines function, not class. did perhaps confuse def
class
in class definition?
Comments
Post a Comment