-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist/ | ||
build/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,24 @@ | ||
# python_game | ||
### 这是一个射击类游戏。当有外星人入侵,火箭射击出子弹,被子弹击中的外星人就会消失。 | ||
# The game Alien Invasion | ||
|
||
- [Game Description] (#Game Description) | ||
- [Operating Environment] (#Operating Environment) | ||
- [Page Effects] (#Page Effects) | ||
- [Game download] (#Game download) | ||
|
||
## Game Description | ||
|
||
This is a shooting game. When an alien invades, the rocket shoots out a bullet, and the alien hit by the bullet will disappear. | ||
|
||
## Operating Environment | ||
> pygame | ||
> certifi==2019.11.28 | ||
> chardet==3.0.4 | ||
> idna==2.8 | ||
> soupsieve==1.9.5 | ||
> urllib3==1.25.7 | ||
## Page Effects | ||
<img src="./images/game.png" alt="Page renderings" /> | ||
|
||
## Game download | ||
[Download alien invasion game]() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 游戏《外星人入侵》 | ||
|
||
- [游戏说明](#游戏说明) | ||
- [运行环境](#运行环境) | ||
- [页面效果](#页面效果) | ||
- [游戏下载](#游戏下载) | ||
|
||
## 游戏说明 | ||
|
||
这是一个射击类游戏。当有外星人入侵,火箭射击出子弹,被子弹击中的外星人就会消失。 | ||
|
||
## 运行环境 | ||
> pygame | ||
> certifi==2019.11.28 | ||
> chardet==3.0.4 | ||
> idna==2.8 | ||
> soupsieve==1.9.5 | ||
> urllib3==1.25.7 | ||
windows安装pygame步骤: | ||
```sh | ||
python --version | ||
``` | ||
1. 查看python版本,选择合适的pygame版本。如:我的是python3.7,所以就选择cp37 | ||
2. 查看系统版本,我的是64位的,所以我选择win_amd64 | ||
3. 确定好下载版本信息,在[pygame官网](https://github.com/pygame/pygame/releases)下载相应的pygame文件 | ||
4. 安装pygame | ||
```sh | ||
pip install --user xxx.whl(pygame文件名) | ||
``` | ||
|
||
其他系统自己探索安装。 | ||
|
||
## 页面效果 | ||
<img src="./images/game.png" alt="页面效果图" /> | ||
|
||
## 游戏下载 | ||
[下载《外星人入侵》游戏]() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# -*- mode: python ; coding: utf-8 -*- | ||
|
||
|
||
block_cipher = None | ||
|
||
|
||
a = Analysis( | ||
['alien_invasion.py'], | ||
pathex=[], | ||
binaries=[], | ||
datas=[('images/alien.png', 'images'),('images/ship.bmp','images'),('high_score.json','.'),('music/Explo_Large.wav','music'),('music/Explo_Small.wav','music'),('music/Bullet_Whiz.wav','music'),('music/order_music.mp3','music')], | ||
hiddenimports=['pygame.pkgdata'], | ||
hookspath=[], | ||
hooksconfig={}, | ||
runtime_hooks=[], | ||
excludes=[], | ||
win_no_prefer_redirects=False, | ||
win_private_assemblies=False, | ||
cipher=block_cipher, | ||
noarchive=False, | ||
) | ||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) | ||
|
||
exe = EXE( | ||
pyz, | ||
a.scripts, | ||
a.binaries, | ||
a.zipfiles, | ||
a.datas, | ||
[], | ||
name='alien_invasion', | ||
debug=False, | ||
bootloader_ignore_signals=False, | ||
strip=False, | ||
upx=True, | ||
upx_exclude=[], | ||
runtime_tmpdir=None, | ||
console=False, | ||
disable_windowed_traceback=False, | ||
argv_emulation=False, | ||
target_arch=None, | ||
codesign_identity=None, | ||
entitlements_file=None, | ||
icon='alien.ico', | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
import pygame | ||
import os | ||
import sys | ||
|
||
|
||
def get_resource_path(relative_path): | ||
if hasattr(sys, '_MEIPASS'): | ||
return os.path.join(sys._MEIPASS, relative_path) | ||
return os.path.join(os.path.abspath("."), relative_path) | ||
|
||
|
||
def explosion_large(): | ||
# 外星人到达了屏幕底部或者撞到飞船的大爆炸声 | ||
explosion_large = pygame.mixer.Sound("music/Explo_Large.wav") | ||
explosion_large = pygame.mixer.Sound(get_resource_path("music/Explo_Large.wav")) | ||
explosion_large.play() | ||
|
||
|
||
def explosion_small(): | ||
# 增加子弹和外星人碰撞的小爆炸声 | ||
explosion_small = pygame.mixer.Sound("music/Explo_Small.wav") | ||
explosion_small = pygame.mixer.Sound(get_resource_path("music/Explo_Small.wav")) | ||
explosion_small.play() | ||
|
||
|
||
def bullet_whiz(): | ||
# 增加子弹射出的biu声 | ||
bullet_whiz = pygame.mixer.Sound("music/Bullet_Whiz.wav") | ||
bullet_whiz = pygame.mixer.Sound(get_resource_path("music/Bullet_Whiz.wav")) | ||
bullet_whiz.play() | ||
|
||
|
||
def bg_music(): | ||
# 游戏背景音乐(若游戏开始就一直播放) | ||
pygame.mixer.music.load("music/order_music.mp3") | ||
pygame.mixer.music.load(get_resource_path("music/order_music.mp3")) | ||
|