0

Hello everyone, I'm working on an assignment that requires a game that drops multiple objects that need to be caught. I'm using multiple classes and the current one is raising a type error.

" File "C:/Users/Joe/Documents/School/I-210/Final/game.py", line 118, in main
gift = Present()
TypeError: __init__() takes at least 2 arguments (1 given)"

I've tried googling and finding my error, but according to my textbook and anything I can find, there just must be something here I do not get.

If anyone can look and explain what my mistake is I would greatly appreciate it. I've only been working with Python for a month or so.

here my part of code raising the error:

class Present(games.Sprite):
    image = games.load_image("present.bmp")
    speed = 2
    
    
    def __init__(self, x , y = 1):
        super(Present, self).__init__(image = Present.image,
                                      x = x, y = y,
                                      dy = Present.speed)
    def update(self):
        if self.bottom > games.screen.height:
            self.end_game()
            self.destroy()
            

    def handle_collide(self):
        self.destroy()
        Sled.score.value += 10
        Sled.score.right = games.screen.width - 10

    def end_game(self):
        end_message = games.Message(value = "GAME OVER",
                                    size = 75,
                                    color = color.red,
                                    x = games.screen.width/2,
                                    y = games.screen.height/2,
                                    lifetime = 4 * games.screen.fps,
                                    after_death = games.screen.quit)
        games.screen.add(end_message)

Edited by jdm3: n/a

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by jdm3
0

Oh, that seemed to take care of it. Thanks for the help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.