Raphael Deonova
Raphael Deonova

Reputation: 11

Argument 1 must be type, not pygame.surface on super() call

I'm trying to build a pong game from scratch using Python, pygame, and OOP (I know, not the best language to use OOP). currently have the following class structure:

gameObject(object) || Ball(gameObject) || Paddle(gameObject)

note: Ball extends gameObject

class gameObject:

def __init__(self, gameDisplay):
    (self.screenwidth, self.screenheight) = gameDisplay.get_size()
    self.gameDisplay = gameDisplay


class Ball(gameObject):

def __init__(self,x,y,r,speed,a, gameDisplay):
    super(gameDisplay)
    self.x = int(x)
    self.y = int(y)
    self.r = int(r)
    self.a = int(a)
    self.speed = speed
    self.xspeed = self.speed * math.cos(self.a)
    self.yspeed = self.speed * math.sin(self.a)

When I tried to create a ball, an error shows up:

super(gameDisplay) TypeError: super() argument 1 must be type, not pygame.Surface

can anyone help me on this?

Upvotes: 1

Views: 81

Answers (1)

kaktus_car
kaktus_car

Reputation: 986

You are not using super correctly.

super().__init__(gameDisplay)

This is in python3, since you do not inherit from Object I assumed python3

For more information on super see this Understanding Python super() with __init__() methods

Upvotes: 1

Related Questions