python 3.6.5中的pygame中未显示图像
我在win32上使用Python 3.6.5中的Pygame,我的MarioGround.png没有显示出来。我有两张照片,一张正在工作,另一张没有。我也没有犯错误。以下是我的完整代码(有待开发): 我的Super_Mario_Standing2.png正在出现,但MarioGround.png没有出现。以下是两者的链接:MarioGround.png: Super_Mario_Standing.png:python 3.6.5中的pygame中未显示图像,python,python-3.x,image,pygame,python-3.6,Python,Python 3.x,Image,Pygame,Python 3.6,我在win32上使用Python 3.6.5中的Pygame,我的MarioGround.png没有显示出来。我有两张照片,一张正在工作,另一张没有。我也没有犯错误。以下是我的完整代码(有待开发): 我的Super_Mario_Standing2.png正在出现,但MarioGround.png没有出现。以下是两者的链接:MarioGround.png: Super_Mario_Standing.png: 谢谢你 您混淆了displayWidth和displayHeight变量,这意味着gy变量
谢谢你 您混淆了
displayWidth
和displayHeight
变量,这意味着gy
变量为640(屏幕下方)。只需交换它们(这里也不需要括号):
import pygame
pygame.init()
black = (0,0,0)
white = (255,255,255)
red = (255,0,0)
blue = (0,0,255)
sky_blue = (0,150,225)
green = (0,255,0)
displayWidth = 800
displayHeight = 600
#Final :- pygame.display.set_mode((1365, 1050))
gameDisplay = pygame.display.set_mode((displayWidth,displayHeight))
pygame.display.set_caption('Super Mario')
clock = pygame.time.Clock()
crashed = False
timeOut = False
Quit = False
#50,75
marioStanding = pygame.image.load('Super_Mario_Standing2.png').convert()
marioStanding = pygame.transform.scale(marioStanding, (displayWidth//16,displayHeight//8))
ground = pygame.image.load('MarioGround.png')
def Stand(mx,my):
gameDisplay.blit(marioStanding,(mx,my))
mx = (displayWidth * 0.45)
my = (displayHeight * 0.8)
def makeGround(gx,gy):
gameDisplay.blit(ground,(gx,gy))
gx = (displayHeight * 0.45)
gy = (displayWidth * 0.8)
while not crashed and not timeOut and not Quit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
Quit = True
print (event)
gameDisplay.fill(sky_blue)
makeGround(gx,gy)
Stand(mx,my)
pygame.display.update()
clock.tick(24)
pygame.quit()
quit()
gx = displayWidth * 0.45
gy = displayHeight * 0.8