"""移动的哪吒.py""" import pygame from pygame.locals import * from sys import exit bgfile = '莲花池.png' sprite_image_filename = '哪吒.png' pygame.init() # 初始化pygame引擎 screen = pygame.display.set_mode((640, 480), 0, 32) pygame.display.set_caption("移动的哪吒pygame入门动画") background = pygame.image.load(bgfile).convert() sprite = pygame.image.load(sprite_image_filename) # 角色的x坐标 x = 0. running = True while running: for event in pygame.event.get(): if event.type == QUIT:running = False screen.blit(background, (0,0)) screen.blit(sprite, (x, 100)) x += 1 # x坐标大于640,则回到原处 if x > 640: x -= 640 pygame.display.update() pygame.quit()
李兴球
李兴球的博客是Python创意编程原创博客