Answers for "missing 1 required positional argument when calling class function"

0

missing 1 required positional argument when calling class function

class Ship:
    def __init__(self, user_x, user_y, user_spaceship_width, user_spaceship_height):
        self.x = user_x
        self.y = user_y
        self.width = user_spaceship_width
        self.height = user_spaceship_height

    def draw_user_ship(self, win):
        win.blit(RED_SPACESHIP, (self.x, self.y, self.width, self.height))

def draw_win():
    win.blit(BG, (0, 0))

    ship = Ship(user_x, user_y, user_spaceship_width, user_spaceship_height)#YOU HAVE TO WRITE THIS BEFORE CALLING THE FUNCTION. THIS IS CALLED INITIATING A FUNCTION.
    ship.draw_user_ship(win)#AFTER YOU'VE INITIATED THE FUNCTION, YOU HAVE TO CALL IT WITH THE NAME YOU'VE INITIATED IT, IN THIS CASE IT'S ship, NOT Ship WITH THE CAPITOL LETTER.

    pygame.display.update()
Posted by: Guest on October-22-2021

Code answers related to "missing 1 required positional argument when calling class function"

Browse Popular Code Answers by Language