Home > Software design >  I am making a game on pygame but when I come a to the 'WIN.blit', it gives me an error
I am making a game on pygame but when I come a to the 'WIN.blit', it gives me an error

Time:10-27

I am making a game on pygame but when I come a to the 'WIN.blit', it gives me an error. I am using MacOs. I think the problem is the width and the height which I set to 900 , 500. Please help me out.

    import pygame
    import os

    WIDTH, HEIGHT = 900, 500
    WIN = pygame.display.set_mode((WIDTH, HEIGHT))
    pygame.display.set_caption("Boom Boom!")

    WHITE = (255, 255, 255)

    FPS = 60

    YELLOW_SPACESHIP_IMAGE = pygame.image.load(os.path.join('Assets', 
    'spaceship_yellow.png'))
    RED_SPACESHIP_IMAGE = pygame.image.load(os.path.join('Assets', 'spaceship_red.png'))

    def draw_window():
      WIN.fill(WHITE)
      WIN.blit(YELLOW_SPACESHIP_IMAGE, 300, 200) 
      pygame.display.update() 

    

CodePudding user response:

The 2nd argument of blit is a tuple with the coordinates:

WIN.blit(YELLOW_SPACESHIP_IMAGE, 300, 200)

WIN.blit(YELLOW_SPACESHIP_IMAGE, (300, 200)) 
  • Related