# coding:utf-8 import pygame, sys, random, time, easygui from pygame.locals import * # 初始化pygame环境 pygame.init() # 创建一个长宽分别为480/650窗口 canvas = pygame.display.set_mode((480, 650)) canvas.fill((255, 255, 255)) # 设置窗口标题 pygame.display.set_caption("飞机大战") bg = pygame.image.load("images/bg1.png") enemy1 = pygame.image.load("images/enemy1.png") enemy2 = pygame.image.load("images/enemy2.png") enemy3 = pygame.image.load("images/enemy3.png") b = pygame.image.load("images/bullet1.png") h = pygame.image.load("images/hero.png") #开始游戏图片 startgame=pygame.image.load("images/startGame.png") #logo图片 logo=pygame.image.load("images/LOGO.png") #暂停图片 pause = pygame.image.load("images/game_pause_nor.png") # 添加时间间隔的方法 def isActionTime(lastTime, interval): if lastTime == 0: return True currentTime = time.time() return currentTime - lastTime >= interval # 定义Sky类 class Sky(): def __init__(self): self.width = 480 self.height = 852 self.img = bg self.x1 = 0 self.y1 = 0 self.x2 = 0 self.y2 = -self.height # 创建paint方法 def paint(self):
Python飞机大战+图片
于 2022-05-06 13:30:26 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)