python - 无法呼叫玩家
问题描述
我正在尝试制作类似游戏的东西,它是一个宇宙飞船游戏我有图片 spaceship.png 和 player.png 但我看不到玩家我只能看到图标和黑屏
import pygame
pygame.init()
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption("1st game")
icon = pygame.image.load("Spaceship.png")
pygame.display.set_icon(icon)
playerImg = pygame.image.load('player.png')
playerX = 370
playerY = 600
def player():
screen.blit(playerImg, (playerX, playerY))
running = True
while running:
screen.fill((0, 0, 0))
player()
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.display.update()
但它只显示黑屏,不显示播放器
解决方案
屏幕尺寸为 800x600。玩家的 y 坐标为 600。因此玩家在底部的窗口之外。
改变玩家的坐标:
playerY = 600
playerY = 480
推荐阅读
- r - 如何按时间戳创建值的有向图
- java - 无法使用 java 流创建数组组合
- reactjs - 在数组映射中反应原生 if else 条件
- javascript - Highcharts:与图表一起自动缩放渲染形状?
- c# - 使用 Confluent.Kafka 消费者库的 Kafka 消息密钥为空
- elasticsearch - 如何创建嵌套的 Kibana 查询?
- linux - 未在引导时为计算模块 3 eMMC 设置 udev 标记 systemd
- function - 按类别在产品价格上加一定金额
- android - DevOpS 无法构建 Xamarin 应用程序
- flutter - 使用颤振应用程序在 Android 上启动 Google 表格应用程序