【问题标题】:I am making a game on pygame but when I come a to the 'WIN.blit', it gives me an error我正在 pygame 上制作游戏,但是当我进入“WIN.blit”时,它给了我一个错误
【发布时间】:2021-10-26 07:21:23
【问题描述】:

我正在 pygame 上制作游戏,但是当我进入“WIN.blit”时,它给了我一个错误。我正在使用 MacOs。我认为问题在于我设置为 900 、 500 的宽度和高度。请帮帮我。

    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() 

    

【问题讨论】:

标签: python python-3.x pygame pygame-surface pygame-clock


【解决方案1】:

blit 的第二个参数是一个带有坐标的元组:

WIN.blit(YELLOW_SPACESHIP_IMAGE, 300, 200)

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    • 1970-01-01
    • 2021-05-23
    • 1970-01-01
    相关资源
    最近更新 更多