0
我目前遇到的问题是我的图像似乎是自己填充屏幕,我该如何解决这个问题?雪碧问题
import pygame, os, sys from pygame.locals import* pygame.init() sHEIGHT = 600 sWIDTH = 800 gName = "Survive" fps = pygame.time.Clock() FPS = 10 GD = pygame.display.set_mode((sWIDTH,sHEIGHT)) class Main: white = (255,255,255) def display(white): pygame.display.set_caption(gName) GD.fill(white) def player1(): img ="Images/" health = 100 global movex global movexchange global movey global moveychange global imgplayer1 movex = 400 movey = 400 movexchange = 0 moveychange = 0 imgplayer1 = pygame.image.load(os.path.join(img, "Human.png")) pygame.display.update() def gameLoop(): fps.tick(FPS) while True: print(fps) global movexchange global moveychange global movex global movey for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_a: moveychange = 0 movexchange -=5 if event.key == pygame.K_w: moveychange -=5 movexchange =0 if event.key == pygame.K_s: moveychange += 5 movexchange = 0 if event.key == pygame.K_d: moveychange = 0 movexchange +=5 if event.type == pygame.KEYUP: if event.key == pygame.K_a: movexchange =0 moveychange =0 if event.key == pygame.K_w: movexchange =0 moveychange =0 if event.key == pygame.K_s: movexchange =0 moveychange =0 if event.key == pygame.K_d: movexchange =0 moveychange =0 movex += movexchange movey += moveychange GD.blit(imgplayer1,(movex,movey)) pygame.display.update() display(white) player1() gameLoop()
没有人有任何想法,为什么发生这种情况,我该如何解决这一问题?
非常感谢你对我的帮助。我一直在这个问题上停留了10个小时。我现在只有4天的时间没有任何指导。 再次,非常感谢您解决这个问题,并教我当我需要使用大写和小写 – zerrith
顺便说一句:[编程与Python和pygame街机游戏](http://programarcadegames.com/) – furas
感谢您的额外资源: ) – zerrith