feat: make it web/pygbag deploy compatible
This commit is contained in:
22
README.md
22
README.md
@@ -1,24 +1,10 @@
|
||||
<h1 align="center">
|
||||
<img width="320" height="288" src="https://gitea.redturtle.foo/crayonix/tetri5/raw/branch/main/resource/image/title_screen.png?raw=true">
|
||||
<img width="320" height="288" src="https://gitea.redturtle.foo/crayonix/tetri5/raw/branch/main/data/image/title_screen.png?raw=true">
|
||||
<br>
|
||||
</h1>
|
||||
|
||||
<h4 align="center">A full featured game of falling shapes using python's <a href="https://www.pygame.org/wiki/about" target="_blank">pygame</a> library.</h4>
|
||||
|
||||
<p align="center">
|
||||
<a target="_blank" href="https://lgtm.com/projects/g/gio101046/tetri5/alerts/">
|
||||
<img src="https://img.shields.io/lgtm/alerts/g/gio101046/tetri5.svg?logo=lgtm&logoWidth=18"
|
||||
alt="looks good to me">
|
||||
</a>
|
||||
<a target="_blank" href="https://lgtm.com/projects/g/gio101046/tetri5/context:python">
|
||||
<img src="https://img.shields.io/lgtm/grade/python/g/gio101046/tetri5.svg?logo=lgtm&logoWidth=18"></a>
|
||||
<a target="_blank" href="https://trello.com/b/3BxntLgZ/tetri5">
|
||||
<img src="https://img.shields.io/badge/-Trello-blue?logo=trello">
|
||||
</a>
|
||||
<!-- <a target="_blank" href="https://saythanks.io/to/giovaniluisrodriguez@gmail.com">
|
||||
<img src="https://img.shields.io/badge/SayThanks.io-%E2%98%BC-1EAEDB.svg">
|
||||
</a> -->
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
@@ -90,3 +76,9 @@ Pull requests are welcome. For major changes, please open an issue first to disc
|
||||
|
||||
## License
|
||||
[MIT](https://choosealicense.com/licenses/mit/)
|
||||
|
||||
|
||||
```TODO
|
||||
pip install --target __pypackages__/3.12/lib/ websockets==15.0.1
|
||||
pip install --target __pypackages__/3.12/lib/ PyYAML==6.0.2
|
||||
```
|
||||
75
build.py
75
build.py
@@ -1,75 +0,0 @@
|
||||
from cx_Freeze import setup, Executable
|
||||
import sys
|
||||
|
||||
base = None
|
||||
if sys.platform == 'win32':
|
||||
base = "Win32GUI"
|
||||
|
||||
shortcut_table = [
|
||||
("DesktopShortcut", # Shortcut
|
||||
"DesktopFolder", # Directory_
|
||||
"Tetri5", # Name
|
||||
"TARGETDIR", # Component_
|
||||
"[TARGETDIR]main.exe", # Target
|
||||
None, # Arguments
|
||||
None, # Description
|
||||
None, # Hotkey
|
||||
None, # Icon
|
||||
None, # IconIndex
|
||||
None, # ShowCmd
|
||||
'TARGETDIR' # WkDir
|
||||
)
|
||||
]
|
||||
|
||||
msi_data = {"Shortcut": shortcut_table}
|
||||
bdist_msi_options = {'data': msi_data}
|
||||
|
||||
setup(
|
||||
name="Tetri5",
|
||||
version="1.0.0",
|
||||
description="A full featured tetris game using python's pygame library. https://github.com/gio101046/tetri5",
|
||||
options={
|
||||
"bdist_msi": bdist_msi_options,
|
||||
"build_exe": {
|
||||
"packages": [
|
||||
"pygame",
|
||||
"typing",
|
||||
"types",
|
||||
"copy",
|
||||
"yaml",
|
||||
"random",
|
||||
"sys",
|
||||
"asyncio",
|
||||
"websockets",
|
||||
"json",
|
||||
"queue",
|
||||
"uuid",
|
||||
"threading",
|
||||
"tetri5.entity",
|
||||
"tetri5.game",
|
||||
"tetri5.modal",
|
||||
"tetri5.online",
|
||||
"tetri5.scene",
|
||||
"tetri5.util"
|
||||
],
|
||||
"include_files": [
|
||||
("config.yaml", "config.yaml"),
|
||||
("resource/image/press-start-2p-font.bmp", "resource/image/press-start-2p-font.bmp"),
|
||||
("resource/image/tetris_icon.png", "resource/image/tetris_icon.png"),
|
||||
("resource/image/title_screen.png", "resource/image/title_screen.png"),
|
||||
("resource/sound/four_lines_complete.ogg", "resource/sound/four_lines_complete.ogg"),
|
||||
("resource/sound/game_over.ogg", "resource/sound/game_over.ogg"),
|
||||
("resource/sound/level_up.ogg", "resource/sound/level_up.ogg"),
|
||||
("resource/sound/line_complete.ogg", "resource/sound/line_complete.ogg"),
|
||||
("resource/sound/option_change.wav", "resource/sound/option_change.wav"),
|
||||
("resource/sound/piece_rotate.ogg", "resource/sound/piece_rotate.ogg"),
|
||||
("resource/sound/piece_set.ogg", "resource/sound/piece_set.ogg"),
|
||||
("resource/sound/theme_music_multi.ogg", "resource/sound/theme_music_multi.ogg"),
|
||||
("resource/sound/theme_music_single.ogg", "resource/sound/theme_music_single.ogg"),
|
||||
("resource/sound/you_win.ogg", "resource/sound/you_win.ogg")
|
||||
]
|
||||
}
|
||||
},
|
||||
executables=[Executable("main.py", base=base)]
|
||||
)
|
||||
|
||||
@@ -4,21 +4,21 @@ window:
|
||||
title: "Tetri5"
|
||||
|
||||
sound:
|
||||
theme-music-single: "resource/sound/theme_music_single.ogg"
|
||||
theme-music-multi: "resource/sound/theme_music_multi.ogg"
|
||||
option-change: "resource/sound/option_change.wav"
|
||||
piece-rotate: "resource/sound/piece_rotate.ogg"
|
||||
piece-set: "resource/sound/piece_set.ogg"
|
||||
line-complete: "resource/sound/line_complete.ogg"
|
||||
four-lines-complete: "resource/sound/four_lines_complete.ogg"
|
||||
level-up: "resource/sound/level_up.ogg"
|
||||
game-over: "resource/sound/game_over.ogg"
|
||||
you-win: "resource/sound/you_win.ogg"
|
||||
theme-music-single: "data/sound/theme_music_single.ogg"
|
||||
theme-music-multi: "data/sound/theme_music_multi.ogg"
|
||||
option-change: "data/sound/option_change.ogg"
|
||||
piece-rotate: "data/sound/piece_rotate.ogg"
|
||||
piece-set: "data/sound/piece_set.ogg"
|
||||
line-complete: "data/sound/line_complete.ogg"
|
||||
four-lines-complete: "data/sound/four_lines_complete.ogg"
|
||||
level-up: "data/sound/level_up.ogg"
|
||||
game-over: "data/sound/game_over.ogg"
|
||||
you-win: "data/sound/you_win.ogg"
|
||||
|
||||
image:
|
||||
title-screen: "resource/image/title_screen.png"
|
||||
window-icon: "resource/image/tetris_icon.png"
|
||||
font: "resource/image/press-start-2p-font.bmp"
|
||||
title-screen: "data/image/title_screen.png"
|
||||
window-icon: "data/image/tetris_icon.png"
|
||||
font: "data/image/press-start-2p-font.bmp"
|
||||
|
||||
position:
|
||||
# title scene
|
||||
|
Before Width: | Height: | Size: 192 KiB After Width: | Height: | Size: 192 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
BIN
data/sound/option_change.ogg
Normal file
BIN
data/sound/option_change.ogg
Normal file
Binary file not shown.
7
main.py
7
main.py
@@ -3,17 +3,18 @@
|
||||
https://strategywiki.org/wiki/Tetris/Getting_Started
|
||||
https://tetris.com/play-tetris
|
||||
'''
|
||||
|
||||
import asyncio
|
||||
from tetri5.game import Game
|
||||
from tetri5.util import ConfigurationManager
|
||||
|
||||
def main() -> None:
|
||||
async def run_game():
|
||||
ConfigurationManager.init()
|
||||
Game.init()
|
||||
|
||||
while True:
|
||||
Game.update()
|
||||
Game.draw()
|
||||
await asyncio.sleep(0) # yield control to browser
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
asyncio.run(run_game())
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
cx-Freeze==6.7
|
||||
importlib-metadata==4.6.1
|
||||
pygame==2.0.1
|
||||
PyYAML==5.4.1
|
||||
websockets==9.1
|
||||
zipp==3.5.0
|
||||
asarPy==1.0.1
|
||||
pygame==2.5.2
|
||||
pygbag==0.9.2
|
||||
PyYAML==6.0.2
|
||||
websockets==15.0.1
|
||||
|
||||
Binary file not shown.
@@ -52,7 +52,7 @@ class Game:
|
||||
cls._current_scene.draw(cls.screen)
|
||||
|
||||
# update display
|
||||
pygame.display.update()
|
||||
pygame.display.flip()
|
||||
|
||||
@classmethod
|
||||
def change_scene(cls, scene: Scene) -> None:
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import asyncio
|
||||
import sys
|
||||
sys.path.append("__pypackages__/3.12/lib/")
|
||||
import websockets
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import queue # refer to https://docs.python.org/3/library/queue.html for cross threading communication
|
||||
import uuid
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import yaml
|
||||
import sys
|
||||
sys.path.append("__pypackages__/3.12/lib/")
|
||||
import yaml # non-native package
|
||||
|
||||
import pygame
|
||||
from typing import Tuple
|
||||
|
||||
@@ -7,7 +10,7 @@ from typing import Tuple
|
||||
"""
|
||||
class ConfigurationManager:
|
||||
|
||||
CONFIG_FILE_LOCATION = "config.yaml"
|
||||
CONFIG_FILE_LOCATION = "data/config.yaml"
|
||||
_configuration = []
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user