我呢
是一位菜鸟程序员
最近在学如何使用pygame
可是出了点小问题
使用global后
有一行代码无法访问
哪位大佬能帮我看一下
代码如下:
import pygame
import sys
pygame.init()
global screen
screen = pygame.display.set_mode((400,300))
pygame.display.set_caption('鸟儿躲避子弹')
screen.fill((255,255,255))
def bird():
global img
img = pygame.image.load('bird3.gif')
screen.blit(img,(0,0))
pygame.display.flip()
while True:
pygame.init()
position = img.get_rect()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYUP:
if event.key == pygame.K_UP:
position = position.move([5,0])
screen.fill((255,255,255))
screen.blit(img,position)
pygame.display.flip()
不胜感激
好人一生平安



