资源简介
python小游戏《外星人入侵》,源码下载,包括矢量图和代码部分。
代码片段和文件信息
import pygame
from pygame.sprite import Sprite
class Alien(Sprite):
‘‘‘表示单个外星人的类‘‘‘
def __init__(selfai_settingsscreen):
‘‘‘初始化外星人并设置其起始位置‘‘‘
super(Alienself).__init__()
self.screen=screen
self.ai_settings=ai_settings
#加载外星人图像,并设置其rect属性
self.image=pygame.image.load(‘images/alien.bmp‘)
self.rect=self.image.get_rect()
#每个外星人最初都在屏幕左下角附近
self.rect.x=self.rect.width
self.rect.y=self.rect.height
#储存外星人的准确位置
self.x=float(self.rect.x)
def blitme(self):
‘‘‘在指定位置绘制外星人‘‘‘
self.screen.blit(self.imageself.rect)
def update(self):
‘‘‘向右移动外星人‘‘‘
self.x+=self.ai_settings.alien_speed_factor
self.rect.x=self.x
def check_edges(self):
‘‘‘如果外星人位于屏幕边缘,就返回True‘‘‘
screen_rect=self.screen.get_rect()
if self.rect.right>=screen_rect.right:
return True
elif self.rect.left<=0:
return True
def update(self):
‘‘‘向左或向右移动外星人‘‘‘
self.x+=(self.ai_settings.alien_speed_factor*self.ai_settings.fleet_direction)
self.rect.x=self.x
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-04-25 00:12 __pycache__\
文件 1646 2018-04-18 22:00 __pycache__\alien.cpython-36.pyc
文件 1266 2018-04-16 22:58 __pycache__\bullet.cpython-36.pyc
文件 1258 2018-04-22 09:42 __pycache__\button.cpython-36.pyc
文件 6304 2018-04-25 00:12 __pycache__\game_functions.cpython-36.pyc
文件 815 2018-04-23 21:12 __pycache__\game_stats.cpython-36.pyc
文件 2669 2018-04-24 20:29 __pycache__\scoreboard.cpython-36.pyc
文件 1419 2018-04-24 20:41 __pycache__\settings.cpython-36.pyc
文件 1588 2018-04-24 20:45 __pycache__\ship.cpython-36.pyc
文件 1233 2018-04-18 21:36 alien.py
文件 1344 2018-04-26 23:47 alien_invasion.py
文件 984 2018-04-16 22:46 bullet.py
文件 1047 2018-04-19 22:52 button.py
文件 7327 2018-04-25 00:12 game_functions.py
文件 502 2018-04-23 20:58 game_stats.py
目录 0 2018-04-24 20:33 images\
文件 10494 2018-04-17 09:24 images\alien.bmp
文件 5061 2018-04-24 20:07 images\ship.bmp
文件 7046 2018-04-13 22:43 images\ship1.bmp
文件 117824 2018-04-13 22:44 images\ship2.bmp
文件 2466 2018-04-24 20:29 scoreboard.py
文件 1197 2018-04-24 20:41 settings.py
文件 1449 2018-04-24 20:45 ship.py
- 上一篇:Flask项目实战-超市商品管理平台
- 下一篇:LBP算法实现
相关资源
- Flask项目实战-超市商品管理平台
- pythonreader.rar
- Python Scrapy爬虫爬取微博和微信公众号
- python写盛金法求一元三次方方程解
- 老男孩Python2018基础高级进阶(28周)
- python http服务器搭建
- Python输入年份月份显示日历
- python实现百度坐标和世界经纬度坐标
- 利用OpenCV检测人脸python程序
- JSYX2.0.zip
- Python题目汇总含答案pdf
- 模态分解emd算法Python实现
- Python读取Las与转换为TXT.zip
- backup.sh.py
- BSTestRunner.pypython3
- SI模型,影响力传播模型,传染病模型
- python自动抓取网页中的pdf文件
- python爬虫网站图片
- Anaconda3 for MacOSX x64百度云
- python16to8
- freetype的python代码
- selenium+python 自动化测试 ---登陆界面测
- OpenCV-Python实现的图片拼接源代码
- 多商品流点弧模型 python+gurobi
- dbfpy操作dbf文件
- python实现果蝇优化算法,测试函数为
- 通过python实现批量excel转pdf代码
- python实现BM匹配算法
- 新浪财经24小时python爬虫程序内置企业
- 基于python实现的ICA过程
评论
共有 条评论