[Tutor] Type error when doing Pygame
Cravan
savageapple850 at gmail.com
Sat Sep 28 07:53:57 EDT 2019
Dear Alan and Cameron,
Thank you for your input. However, after removing the first "screen" argument, I receive another error:
###################
Traceback (most recent call last):
File "final_project.py", line 134, in <module>
g.run()
File "final_project.py", line 37, in run
self.draw()
File "final_project.py", line 64, in draw
self.food_food(5, 5, self.food_bar)
File "final_project.py", line 50, in food_food
pygame.draw.rect(self, GREEN, fill_rect)
TypeError: argument 1 must be pygame.Surface, not Game
I apologise if this seems like a really silly question, but I don’t really code much and am not really proficient in coding. May I know how to rectify this?
Thanks,
Cravan
On 28/9/19, 7:25 PM, "Tutor on behalf of Alan Gauld via Tutor" <tutor-bounces+savageapple850=gmail.com at python.org on behalf of tutor at python.org> wrote:
On 28/09/2019 08:48, Cravan wrote:
> class Game:
>
> def food_food(self, x, y, cool):
>
>
> And here’s the Error I’m receiving:
>
>
>
> ################################
>
> Traceback (most recent call last):
>
>
> File "final_project.py", line 65, in draw
>
> self.food_food(screen, 5, 5, self.food_bar)
>
> TypeError: food_food() takes 4 positional arguments but 5 were given
The definition says 4 parameters including the implicit self.
But you pass 4 parameters plus self. Hence the error.
It looks as if you are passing an extra value - presumably 'screen'
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list