资源简介
python项目飞机大战python项目飞机大战

代码片段和文件信息
import random
import pygame
frame = 60
SCREEN_RECT = pygame.Rect(0 0 512 768)
CREATE_ENEMY = pygame.USEREVENT
CREATE_BULLET = pygame.USEREVENT + 1
CREATE_BOMB = pygame.USEREVENT + 2
class GameSprite(pygame.sprite.Sprite):
def __init__(self image_name speed=1 speedy=0):
super().__init__()
self.image = pygame.image.load(image_name)
self.rect = self.image.get_rect()
self.speed = speed
self.speedy = speedy
def update(self):
self.rect.y += self.speed
class BackGround(GameSprite):
def __init__(self is_first=Falsebj_num=1):
super().__init__(“./images/img_bg_level_%d.jpg“ % bj_num)
if is_first:
self.rect.y = -SCREEN_RECT.height
def update(self):
super().update()
if self.rect.y >= SCREEN_RECT.height:
self.rect.y = -SCREEN_RECT.height
class Enemy(GameSprite):
def __init__(self):
super().__init__(“./images/img-plane_%d.png“ % random.randint(1 7))
self.speed = random.randint(2 5)
self.rect.x = random.randint(0 SCREEN_RECT.width - self.rect.width)
self.rect.y = -self.rect.height
def update(self):
super().update()
if self.rect.y >= SCREEN_RECT.height:
self.kill()
class Bullet(GameSprite):
def __init__(self):
super().__init__(“./images/bullet_5.png“ -2)
class Hero(GameSprite):
def __init__(self):
super().__init__(“./images/hero.png“)
self.rect.centerx = SCREEN_RECT.centerx
self.rect.bottom = SCREEN_RECT.bottom - 20
def update(self):
self.rect.x += self.speed
self.rect.y += self.speedy
if self.rect.x > SCREEN_RECT.width - self.rect.width:
self.rect.x = SCREEN_RECT.width - self.rect.width
elif self.rect.x < 0:
self.rect.x = 0
if self.rect.y < 0:
self.rect.y = 0
elif self.rect.y > SCREEN_RECT.height - self.rect.height:
self.rect.y = SCREEN_RECT.height - self.rect.height
def fire(self bullet_group):
for i in [0 1 2]:
bullet = Bullet()
bullet.rect.centerx = self.rect.centerx
bullet.rect.bottom = self.rect.y - 20 * i
bullet_group.add(bullet)
class Bomb(GameSprite):
def __init__(self):
super().__init__(“./images/bomb_supply.png“)
self.speed = 2
self.rect.x = random.randint(0 SCREEN_RECT.width - self.rect.width)
self.rect.y = -self.rect.height
def update(self):
super().update()
if self.rect.y >= SCREEN_RECT.height:
self.kill()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-10-24 13:58 飞机大战\
目录 0 2019-08-16 14:58 飞机大战\images\
文件 5289 2017-07-16 05:06 飞机大战\images\again.png
文件 40500 2017-07-16 05:06 飞机大战\images\background.png
文件 6833 2017-07-16 05:06 飞机大战\images\bomb.png
文件 8795 2017-07-16 05:06 飞机大战\images\bomb_supply.png
文件 1366 2017-07-16 05:06 飞机大战\images\bullet1.png
文件 1359 2017-07-16 05:06 飞机大战\images\bullet2.png
文件 1206 2018-06-27 20:36 飞机大战\images\bullet_5.png
文件 8226 2017-07-16 05:06 飞机大战\images\bullet_supply.png
文件 72913 2018-06-27 20:36 飞机大战\images\eff2.png
文件 73449 2018-06-27 20:36 飞机大战\images\eff4.png
文件 4064 2017-07-16 05:06 飞机大战\images\enemy1.png
文件 4518 2017-07-16 05:06 飞机大战\images\enemy1_down1.png
文件 4963 2017-07-16 05:06 飞机大战\images\enemy1_down2.png
文件 6373 2017-07-16 05:06 飞机大战\images\enemy1_down3.png
文件 3032 2017-07-16 05:06 飞机大战\images\enemy1_down4.png
文件 9038 2017-07-16 05:06 飞机大战\images\enemy2.png
文件 10971 2017-07-16 05:06 飞机大战\images\enemy2_down1.png
文件 11991 2017-07-16 05:06 飞机大战\images\enemy2_down2.png
文件 13629 2017-07-16 05:06 飞机大战\images\enemy2_down3.png
文件 4968 2017-07-16 05:06 飞机大战\images\enemy2_down4.png
文件 9844 2017-07-16 05:06 飞机大战\images\enemy2_hit.png
文件 44952 2017-07-16 05:06 飞机大战\images\enemy3_down1.png
文件 50517 2017-07-16 05:06 飞机大战\images\enemy3_down2.png
文件 55669 2017-07-16 05:06 飞机大战\images\enemy3_down3.png
文件 61564 2017-07-16 05:06 飞机大战\images\enemy3_down4.png
文件 67708 2017-07-16 05:06 飞机大战\images\enemy3_down5.png
文件 11786 2017-07-16 05:06 飞机大战\images\enemy3_down6.png
文件 43848 2017-07-16 05:06 飞机大战\images\enemy3_hit.png
文件 42024 2017-07-16 05:06 飞机大战\images\enemy3_n1.png
............此处省略35个文件信息
相关资源
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
评论
共有 条评论