Space Invaders

Joined
Dec 3, 2022
Messages
1
Reaction score
0
I was coding Space Invaders when I got the message TypeError: Ship.draw() missing 1 required positional argument: 'window'

My code is as follows:

Python:
class Ship:
    def _init_(self, x, y, health=100):
        self.x = x
        self.y = y
        self.health = health
        self.ship_img = None
        self.laser_img = RED_LASER
        self.laser = []
        self,cool_down_counter = 0




    def draw(self, window):
        pygame.draw.rect(window, (255,0,0),(self.x, self.y, 50, 50),0)
    
def main():
    run = True
    FPS = 60
    level = 1
    lives = 5
    clock = pygame.time.Clock()
    main_font = pygame.font.SysFont("comicsans", 25)

    ship = Ship()

    def redraw_window():
        WIN.blit(BG, (0,0))
        #draw text
        lives_label = main_font.render(f"Lives: {lives}", 1, (255,255,255))
        level_label = main_font.render(f"Level: {level}", 1, (255,255,255))

        WIN.blit(lives_label, (10, 10))
        WIN.blit(level_label, (650, 10))

        Ship.draw(WIN)

I can't seem to figure out why it is saying this any help would be appreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top