Merge branch 'master' into opengl

This commit is contained in:
星外之神 2022-06-17 11:38:58 +08:00
commit 4cd28ea606
3 changed files with 101 additions and 3 deletions

89
.github/workflows/build-pr.yml vendored Normal file
View File

@ -0,0 +1,89 @@
name: "Build for PR"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
jobs:
windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python_version:
- '3.10'
name: Windows Python ${{ matrix.python_version }}
steps:
- uses: actions/checkout@v2
- uses: ilammy/msvc-dev-cmd@v1
- name: Use Python ${{ matrix.python_version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python_version }}
- name: 🧳 Install dependencies
run: |
echo y | pip install --no-python-version-warning --disable-pip-version-check pyinstaller
echo y | pip install --no-python-version-warning --disable-pip-version-check nuitka
echo y | pip install --no-python-version-warning --disable-pip-version-check zstandard
echo y | pip install --no-python-version-warning --disable-pip-version-check pygame
echo y | pip install --no-python-version-warning --disable-pip-version-check ordered-set
# 使用pyinstaller构建
- name: Build pypvz with pyinstaller
run: |
pyinstaller -F main.py `
-n pypvz-with-python${{ matrix.python_version }}-pyinstaller-x64.exe `
--distpath ./out `
--noconsole `
--add-data="resources;./resources" `
--add-data="pypvz-exec-logo.png;./pypvz-exec-logo.png" `
-i ./pypvz.ico
# 使用Nuitka构建
- name: Show nuitka version
run: |
Get-ChildItem env:
python -m nuitka --version
- name: Build pypvz with Nuitka
run: |
echo y | python -m nuitka --standalone `
--onefile `
--show-progress `
--show-memory `
--output-dir=out `
--windows-icon-from-ico=pypvz.ico `
--include-data-dir=resources=resources `
--include-data-file=c:\hostedtoolcache\windows\python\${{ matrix.python_version }}*\x64\lib\site-packages\pygame\libogg-0.dll=libogg-0.dll `
--include-data-file=c:\hostedtoolcache\windows\python\${{ matrix.python_version }}*\x64\lib\site-packages\pygame\libopus-0.dll=libopus-0.dll `
--include-data-file=c:\hostedtoolcache\windows\python\${{ matrix.python_version }}*\x64\lib\site-packages\pygame\libopusfile-0.dll=libopusfile-0.dll `
--include-data-file=c:\hostedtoolcache\windows\python\${{ matrix.python_version }}*\x64\lib\site-packages\pygame\libvorbisfile-3.dll=libvorbisfile-3.dll `
--include-data-file=c:\hostedtoolcache\windows\python\${{ matrix.python_version }}*\x64\lib\site-packages\pygame\libvorbis-0.dll=libvorbis-0.dll `
--windows-disable-console `
-o ./out/pypvz-with-python${{ matrix.python_version }}-nuitka-msvc-x64.exe `
main.py
# artifact压缩包处上传包含exe和运行环境的文件夹
- name: "Upload binarie directory"
uses: actions/upload-artifact@v2
with:
name: DIR-python-${{ matrix.python_version }}
path: ./out/*.dist
- name: "Upload binaries of pyinstaller"
uses: actions/upload-artifact@v2
with:
name: pyinstaller-python-${{ matrix.python_version }}
path: ./out/*pyinstaller*.exe
- name: "Upload binaries of pyinstaller"
uses: actions/upload-artifact@v2
with:
name: nuitka-python-${{ matrix.python_version }}
path: ./out/*nuitka*.exe

View File

@ -5,7 +5,6 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
on: on:
pull_request:
push: push:
branches: branches:
- master - master

View File

@ -24,6 +24,13 @@ class Level(tool.State):
self.showLittleMenu = False self.showLittleMenu = False
# 导入地图参数 # 导入地图参数
# 这些注释内容是将来增加通过界面后的容错设计,以保证直接通关时不会闪退
# 现在为了明确一开始就没有正确导入地图的错误,没有启用这些设定
# if self.loadMap(): # 表示导入成功
# self.map = map.Map(self.map_data[c.BACKGROUND_TYPE])
# self.map_y_len = self.map.height
# self.setupBackground()
# self.initState()
self.loadMap() self.loadMap()
self.map = map.Map(self.map_data[c.BACKGROUND_TYPE]) self.map = map.Map(self.map_data[c.BACKGROUND_TYPE])
self.map_y_len = self.map.height self.map_y_len = self.map.height
@ -32,9 +39,9 @@ class Level(tool.State):
def loadMap(self): def loadMap(self):
if self.game_info[c.GAME_MODE] == c.MODE_LITTLEGAME: if self.game_info[c.GAME_MODE] == c.MODE_LITTLEGAME:
map_file = 'littleGame_' + str(self.game_info[c.LITTLEGAME_NUM]) + '.json' map_file = f'littleGame_{self.game_info[c.LITTLEGAME_NUM]}.json'
elif self.game_info[c.GAME_MODE] == c.MODE_ADVENTURE: elif self.game_info[c.GAME_MODE] == c.MODE_ADVENTURE:
map_file = 'level_' + str(self.game_info[c.LEVEL_NUM]) + '.json' map_file = f'level_{self.game_info[c.LEVEL_NUM]}.json'
file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))),'resources' , 'data', 'map', map_file) file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))),'resources' , 'data', 'map', map_file)
# 最后一关之后应该结束了 # 最后一关之后应该结束了
try: try:
@ -321,6 +328,9 @@ class Level(tool.State):
# 更新函数每帧被调用,将鼠标事件传入给状态处理函数 # 更新函数每帧被调用,将鼠标事件传入给状态处理函数
def update(self, surface, current_time, mouse_pos, mouse_click): def update(self, surface, current_time, mouse_pos, mouse_click):
# 这些注释内容是将来增加通过界面后的容错设计,以保证直接通关时不会闪退
# if self.done:
# return
self.current_time = self.game_info[c.CURRENT_TIME] = self.pvzTime(current_time) self.current_time = self.game_info[c.CURRENT_TIME] = self.pvzTime(current_time)
if self.state == c.CHOOSE: if self.state == c.CHOOSE:
self.choose(mouse_pos, mouse_click) self.choose(mouse_pos, mouse_click)