I want to make a little snake game with Pygame. I've got a apple class but when I want to create the apple object I get that error: "TypeError: 'module' object is not callable"
I have got absolutely no idea how I can fix it
Class:
class Apple:
def __init__(self, surface, row, colum, scaller):
self.surface = surface
self.scaller = scaller
self.x = int(map1d(row, 0, self.scaller, 0, width))
self.y = int(map1d(colum, 0, self.scaller, 0, height))
def show(self):
pygame.draw.rect(self.surface, (255, 0, 0), (self.x, self.y), width / self.scaller / 2, height / self.scaler / 2)
map1d function:
def map1d(value, min_, max_, scalledMin, scalledMax):
scaller = interp1d([min_, max_], [scalledMin, scalledMax])
return scaller(value)
Main:
if __name__ == "__main__":
width = 700
height = 700
scaller = 35
win = pygame.display.set_mode((width, height))
#here I'm getting the error
apple = Apple(win, random(scaller - 1), random(scaller - 1), scaller)
Traceback (most recent call last):
File "sketch.py", line 48, in <module>
apple = Apple(win, random(scaller - 1), random(scaller - 1), scaller)
TypeError: 'module' object is not callable