I am creating a cookie clicker game, where there is a surface that displays how many cookies I have.
Here is my code for drawing text.
def draw_text(self, text, font_name, size, color, x, y, align="nw"):
font = pg.font.Font(font_name, size)
text_surface = font.render(text, True, color)
text_rect = text_surface.get_rect()
self.screen.blit(text_surface, text_rect)
Then in the new function of my game loop (for when a new game starts), I created a variable:
def new(self):
self.cookie_count = 0
And then finally, I have my drawing function.
def draw(self):
self.draw_text('Cookies: {}'.format(len(self.cookie_count)), self.cookie_font, 105, SKYBLUE, 325, HEIGHT * 3/4, align="nw")
pg.display.update()
Yet, when I run the program, I get:
TypeError: object of type 'int' has no len()
I am new to creating a "score counter" you could call it. But why does
self.draw_text('Cookies: {}'.format(len(self.cookie_count))
give me an error? How come the length of self.cookie_count is not printed?