python - screen.blit 函数在 pygame 中不起作用
问题描述
import pygame, sys
WINDOW_SIZE = (900, 700)
screen = pygame.display.set_mode(WINDOW_SIZE, 0, 32)
pygame.display.set_caption('Pygame Program')
pygame.display.set_icon(pygame.image.load('spaceship (3).png'))
player_img = pygame.image.load('ClipartKey_738895_adobespark.png')
player_X = 130
player_Y = 750
def player():
screen.blit(player_img, (player_X, player_Y))
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
sys.exit()
screen.fill((0, 200, 255))
player()
pygame.display.update()
我的 player() 函数不起作用。它没有显示任何错误,但屏幕保持空白,并且没有显示任何内容
解决方案
坐标 (130, 750) 位于窗口外的底部。更改 y 坐标。例如:
player_Y = 750
player_Y = 150
推荐阅读
- c - 提交非数字后,Scanf 不接受输入
- google-app-engine - gcloud appengine 使用 app.yaml 中的动态 url 路径匹配静态文件路径
- c# - 如何在 LINQ to Entities 中使用包含任意属性选择而不评估 IQueryable?
- php - Doctrine2 - 将数字保存为负值
- powershell - 如何在 Powershell 中从 PDF 文件中的特定单元格获取文本
- select - 用平均值和标准差绘制选定的行 (GNUPlot)
- qt - 使用QT le创建负责发送和接收数据的Bluetooth le服务器
- javascript - 画布渲染分辨率 - 如何在 flex 布局中使用画布
- c# - MS Teams - 像呼叫中心应用程序一样接入当前电话并显示有关呼叫者的其他信息
- javascript - 过滤具有相同 id 的对象数组