二维游戏小程序代码
#二维飞机小游戏
import pygame
import sys
import time
from pygame.locals import * #*代表所有,检测事件
#创建窗口
screen=pygame.display.set_mode((640,632))
#读取图片
img1=pygame.image.load("E:\\7.jpg")#背景图
img2=pygame.image.load("E:\\1.jpg")#玩家
#在窗口中加入对象
while 1==1:
a=10
b=100
for x in range(60):
screen.blit(img1,(0,0))
screen.blit(img2,(50,80))
#刷新窗口,显示所有对象
pygame.display.update()
if x<=30:
a+=1#向右移动10个像素
else:
a-=1
time.sleep(0.1)
#检测用户退出
for event in pygame.event.get():
if event.type==QUIT:#退出
print('正在退出')
sys.exit(0)#手动退出程序
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号