本人运用python编写飞机大战程序,每次玩家有三条生命,方向键控制飞船方向, 空格和Z控制飞船开火
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 879 2018-03-24 17:21 Bullet.py
文件 7838 2018-04-15 17:39 Game_functions.py
文件 25594108 2018-04-01 11:12 Run.exe
文件 1393 2018-04-16 19:51 Run.py
文件 1044 2018-03-31 21:39 Settings.py
文件 1372 2018-03-25 16:06 Ship.py
文件 1077 2018-03-25 12:35 alien.py
文件 532 2018-03-25 14:25 aliens_bullets.py
文件 337 2018-03-24 21:42 bgi.py
文件 1107 2018-03-31 20:08 button.py
文件 238 2018-03-31 21:42 game_stats.py
目录 0 2018-05-08 18:38 images
文件 572893 2018-03-24 23:24 imagesgi.jpg
文件 28398 2018-03-24 13:19 images外星飞船.png
文件 22502 2018-03-31 20:11 images开始游戏.png
文件 61924 2018-03-25 13:42 images激光.png
文件 20503 2018-03-25 14:15 images激光1.png
文件 19208 2018-03-25 14:24 images激光2.png
文件 62764 2018-03-18 20:42 images火箭.png
文件 20302 2018-03-24 13:27 images火箭1.png
文件 23950 2018-03-24 13:25 images飞船.png
文件 25215 2018-03-31 21:48 images飞船2.png
文件 24758 2018-03-31 21:49 images飞船3.png
文件 597 2018-03-25 15:53 laser.py
目录 0 2018-05-08 18:38 music
文件 45759 2018-03-21 21:53 music1311.mp3
文件 5129929 2018-03-21 21:52 musicVictory.mp3
文件 735 2018-04-01 11:12 run.spec
import pygame
from pygame.sprite import Sprite
import random
class Alien(Sprite):
def __init__(self set screen):
super(Alien self).__init__()
self.screen = screen
self.set = set
self.image = pygame.image.load(“images/外星飞船.png“)
self.rect = self.image.get_rect()
self.rect.x = self.rect.width
self.rect.y = 0
self.x = float(self.rect.x)
self.y = float(self.rect.y)
self.direction = 1
‘‘‘
def blit_me(self):
self.screen.blit(self.image self.rect)
‘‘‘
def update(self):
if 1 == random.randint(1 30):
self.direction *= -1
self.x += self.set.alien_speed_factor * self.direction
self.rect.x = self.x
self.y += self.set.fleet_drop_speed
self.rect.y = self.y
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
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 879 2018-03-24 17:21 Bullet.py
文件 7838 2018-04-15 17:39 Game_functions.py
文件 25594108 2018-04-01 11:12 Run.exe
文件 1393 2018-04-16 19:51 Run.py
文件 1044 2018-03-31 21:39 Settings.py
文件 1372 2018-03-25 16:06 Ship.py
文件 1077 2018-03-25 12:35 alien.py
文件 532 2018-03-25 14:25 aliens_bullets.py
文件 337 2018-03-24 21:42 bgi.py
文件 1107 2018-03-31 20:08 button.py
文件 238 2018-03-31 21:42 game_stats.py
目录 0 2018-05-08 18:38 images
文件 572893 2018-03-24 23:24 imagesgi.jpg
文件 28398 2018-03-24 13:19 images外星飞船.png
文件 22502 2018-03-31 20:11 images开始游戏.png
文件 61924 2018-03-25 13:42 images激光.png
文件 20503 2018-03-25 14:15 images激光1.png
文件 19208 2018-03-25 14:24 images激光2.png
文件 62764 2018-03-18 20:42 images火箭.png
文件 20302 2018-03-24 13:27 images火箭1.png
文件 23950 2018-03-24 13:25 images飞船.png
文件 25215 2018-03-31 21:48 images飞船2.png
文件 24758 2018-03-31 21:49 images飞船3.png
文件 597 2018-03-25 15:53 laser.py
目录 0 2018-05-08 18:38 music
文件 45759 2018-03-21 21:53 music1311.mp3
文件 5129929 2018-03-21 21:52 musicVictory.mp3
文件 735 2018-04-01 11:12 run.spec
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)