pygame errors
MRAB
python at mrabarnett.plus.com
Sat Mar 6 22:47:41 EST 2021
On 2021-03-07 03:01, Quentin Bock wrote:
> #Space Invaders!
> #Title and Icon
> pygame.display.set_caption("Space Invaders")
> icon = pygame.image.load('space-invaders.png')
> pygame.display.set_icon(icon)
> #Player
> player_Image = pygame.image.load('player.png')
> player_X = 370
> player_Y = 480
>
> def player():
> screen.blit(player_Image, player_X, player_Y)
>
The position should be given as a 2-tuple, not as 2 separate parameters.
The line should be:
screen.blit(player_Image, (player_X, player_Y))
>
> #Game Loop
> pygame.init()
> screen = pygame.display.set_mode((800, 600))
> running = True
> while running:
>
> screen.fill((128, 128, 128))
>
> for event in pygame.event.get():
> if event.type == pygame.QUIT:
> running = False
> player()
> pygame.display.update()
>
> The window will not display the icon, saying, "invalid destination for blit"
>
> Is this an indentation error? I don't understand why this position
> would be invalid.
>
> link to tutorial I'm following:
>
> https://www.youtube.com/watch?v=FfWpgLFMI7w
>
More information about the Python-list
mailing list