资源简介
Python版的飞机大战源码和素材。素材包括有图片和声音
代码片段和文件信息
# -*- coding: utf-8 -*-
“““
Created on Wed Sep 11 16:36:03 2013
@author: Leo
“““
import pygame
SCREEN_WIDTH = 480
SCREEN_HEIGHT = 800
TYPE_SMALL = 1
TYPE_MIDDLE = 2
TYPE_BIG = 3
# 子弹类
class Bullet(pygame.sprite.Sprite):
def __init__(self bullet_img init_pos):
pygame.sprite.Sprite.__init__(self)
self.image = bullet_img
self.rect = self.image.get_rect()
self.rect.midbottom = init_pos
self.speed = 10
def move(self):
self.rect.top -= self.speed
# 玩家类
class Player(pygame.sprite.Sprite):
def __init__(self plane_img player_rect init_pos):
pygame.sprite.Sprite.__init__(self)
self.image = [] # 用来存储玩家对象精灵图片的列表
for i in range(len(player_rect)):
self.image.append(plane_img.subsurface(player_rect[i]).convert_alpha())
self.rect = player_rect[0] # 初始化图片所在的矩形
self.rect.topleft = init_pos # 初始化矩形的左上角坐标
self.speed = 8 # 初始化玩家速度,这里是一个确定的值
self.bullets = pygame.sprite.Group() # 玩家飞机所发射的子弹的集合
self.img_index = 0 # 玩家精灵图片索引
self.is_hit = False # 玩家是否被击中
def shoot(self bullet_img):
bullet = Bullet(bullet_img self.rect.midtop)
self.bullets.add(bullet)
def moveUp(self):
if self.rect.top <= 0:
self.rect.top = 0
else:
self.rect.top -= self.speed
def moveDown(self):
if self.rect.top >= SCREEN_HEIGHT - self.rect.height:
self.rect.top = SCREEN_HEIGHT - self.rect.height
else:
self.rect.top += self.speed
def moveLeft(self):
if self.rect.left <= 0:
self.rect.left = 0
else:
self.rect.left -= self.speed
def moveRight(self):
if self.rect.left >= SCREEN_WIDTH - self.rect.width:
self.rect.left = SCREEN_WIDTH - self.rect.width
else:
self.rect.left += self.speed
# 敌人类
class Enemy(pygame.sprite.Sprite):
def __init__(self enemy_img enemy_down_imgs init_pos):
pygame.sprite.Sprite.__init__(self)
self.image = enemy_img
self.rect = self.image.get_rect()
self.rect.topleft = init_pos
self.down_imgs = enemy_down_imgs
self.speed = 2
self.down_index = 0
def move(self):
self.rect.top += self.speed
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-09-22 19:19 Python飞机大战\
目录 0 2018-09-22 19:19 Python飞机大战\PythonShootGame-master\
文件 2741 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\gameRole.py
文件 6403 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\mainGame.py
目录 0 2018-09-22 19:19 Python飞机大战\PythonShootGame-master\resources\
目录 0 2018-09-22 19:19 Python飞机大战\PythonShootGame-master\resources\font\
文件 1662 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\font\font.fnt
文件 5193 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\font\font.png
目录 0 2018-09-22 19:19 Python飞机大战\PythonShootGame-master\resources\image\
文件 33518 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\image\background.png
文件 20682 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\image\gameover.png
文件 3388 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\image\shoot.pack
文件 463797 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\image\shoot.png
文件 793 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\image\shoot_background.pack
文件 92377 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\image\shoot_background.png
目录 0 2018-09-22 19:19 Python飞机大战\PythonShootGame-master\resources\sound\
文件 8831 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\achievement.mp3
文件 12327 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\big_spaceship_flying.mp3
文件 7751 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\bullet.mp3
文件 8108 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\bullet.wav
文件 6815 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\button.mp3
文件 11287 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\enemy1_down.mp3
文件 17900 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\enemy1_down.wav
文件 12847 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\enemy2_down.mp3
文件 14444 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\enemy2_down.wav
文件 9415 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\enemy3_down.mp3
文件 71468 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\enemy3_down.wav
文件 117728 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\game_music.mp3
文件 1087532 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\game_music.wav
文件 14615 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\game_over.mp3
文件 44972 2016-06-29 01:29 Python飞机大战\PythonShootGame-master\resources\sound\game_over.wav
............此处省略4个文件信息
相关资源
- 基于Python专用型网络爬虫的设计及实
- 飞机大战源码和素材Python版
- python实现云盘 代码及实验报告
- Packt.Modern.Python.Standard.Library.Cookbook
- mysql-connector-python-2.1.3-py2.7-winx64.msi
- 基于Python的飞机大战项目源码素材包
- OpenCV+python手势识别框架和简单
- 《Python语言程序基础第2版》课后答案
- 用笨办法学python第四版
- Python 3 Text Processing with NLTK 3 Cookbook
- hog_svm_train_python
- 基于python的车牌定位
- Python飞机大战完整素材包字体音乐图
- Python-60DaysRLChallenge中文版强化学习6
- Python-python3实现互信息和左右熵的新词
- python 机器人 开题报告
- 小甲鱼-飞机大战python
- 深入理解Python特性(Python-Tricks).pd
- 计算机网络-自顶向下方法-第6版-pyt
- 从记录到编程--Python在ABAQUS程序化参数
- Text Processing In Python (Python文本处理)
- scapy+python2.7 windows 64位安装包
- python淘宝网指定关键词爬取商品信息
- Deep Learning in Python
- 深度学习Theano教程,python语言
- Python学习实践-sklearn分类算法实践-M
- SVM解兵王问题_python.zip
- 学生成绩管理系统.zip
- 随机信号处理之 经典法谱估计MATLAB和
- 基于django的个人博客
评论
共有 条评论