资源简介
外星人入侵项目,亲自敲下并运行过的,包括了图片资源。整个项目打包过来,打分功能请自行学完后自己动手完善。

代码片段和文件信息
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 check_edges(self):
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
def blitme(self):
“““在制定位置绘制外星人“““
self.screen.blit(self.imageself.rect)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-11-23 16:13 alien_invasion\
文件 1167 2018-11-23 12:46 alien_invasion\alien.py
文件 1209 2018-11-23 17:28 alien_invasion\alien_invasion.py
文件 1029 2018-11-22 10:07 alien_invasion\bullet.py
文件 5384 2018-11-23 17:31 alien_invasion\game_functions.py
文件 244 2018-11-23 17:29 alien_invasion\game_stats.py
目录 0 2018-11-21 18:51 alien_invasion\images\
文件 10494 2018-11-21 18:45 alien_invasion\images\alien.bmp
文件 8694 2018-11-21 18:48 alien_invasion\images\ship.bmp
文件 668 2018-11-23 16:59 alien_invasion\settings.py
文件 1294 2018-11-23 17:13 alien_invasion\ship.py
目录 0 2018-11-23 17:31 alien_invasion\__pycache__\
文件 1457 2018-11-23 12:46 alien_invasion\__pycache__\alien.cpython-34.pyc
文件 1317 2018-11-22 10:13 alien_invasion\__pycache__\bullet.cpython-34.pyc
文件 5104 2018-11-23 17:31 alien_invasion\__pycache__\game_functions.cpython-34.pyc
文件 621 2018-11-23 17:30 alien_invasion\__pycache__\game_stats.cpython-34.pyc
文件 886 2018-11-23 17:27 alien_invasion\__pycache__\settings.cpython-34.pyc
文件 1371 2018-11-23 17:27 alien_invasion\__pycache__\ship.cpython-34.pyc
- 上一篇:合并BN层的python脚本
- 下一篇:初学者练习python编程的100个小程序
相关资源
- 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获取硬件信息
- 量化交易(附python常见函数的使用方
- python 名字用字排行
评论
共有 条评论