diff --git a/README.md b/README.md index 28011f3..fb4e0c8 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,10 @@

- +

A full featured game of falling shapes using python's pygame library.

-

- - looks good to me - - - - - - - -



@@ -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 +``` \ No newline at end of file diff --git a/build.py b/build.py deleted file mode 100644 index d36dd78..0000000 --- a/build.py +++ /dev/null @@ -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)] -) - diff --git a/config.yaml b/data/config.yaml similarity index 75% rename from config.yaml rename to data/config.yaml index ac00579..90b6f98 100644 --- a/config.yaml +++ b/data/config.yaml @@ -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 diff --git a/resource/image/press-start-2p-font.bmp b/data/image/press-start-2p-font.bmp similarity index 100% rename from resource/image/press-start-2p-font.bmp rename to data/image/press-start-2p-font.bmp diff --git a/resource/image/tetris_icon.png b/data/image/tetris_icon.png similarity index 100% rename from resource/image/tetris_icon.png rename to data/image/tetris_icon.png diff --git a/resource/image/title_screen.png b/data/image/title_screen.png similarity index 100% rename from resource/image/title_screen.png rename to data/image/title_screen.png diff --git a/resource/sound/four_lines_complete.ogg b/data/sound/four_lines_complete.ogg similarity index 100% rename from resource/sound/four_lines_complete.ogg rename to data/sound/four_lines_complete.ogg diff --git a/resource/sound/game_over.ogg b/data/sound/game_over.ogg similarity index 100% rename from resource/sound/game_over.ogg rename to data/sound/game_over.ogg diff --git a/resource/sound/level_up.ogg b/data/sound/level_up.ogg similarity index 100% rename from resource/sound/level_up.ogg rename to data/sound/level_up.ogg diff --git a/resource/sound/line_complete.ogg b/data/sound/line_complete.ogg similarity index 100% rename from resource/sound/line_complete.ogg rename to data/sound/line_complete.ogg diff --git a/data/sound/option_change.ogg b/data/sound/option_change.ogg new file mode 100644 index 0000000..5e70f26 Binary files /dev/null and b/data/sound/option_change.ogg differ diff --git a/resource/sound/piece_rotate.ogg b/data/sound/piece_rotate.ogg similarity index 100% rename from resource/sound/piece_rotate.ogg rename to data/sound/piece_rotate.ogg diff --git a/resource/sound/piece_set.ogg b/data/sound/piece_set.ogg similarity index 100% rename from resource/sound/piece_set.ogg rename to data/sound/piece_set.ogg diff --git a/resource/sound/theme_music_multi.ogg b/data/sound/theme_music_multi.ogg similarity index 100% rename from resource/sound/theme_music_multi.ogg rename to data/sound/theme_music_multi.ogg diff --git a/resource/sound/theme_music_single.ogg b/data/sound/theme_music_single.ogg similarity index 100% rename from resource/sound/theme_music_single.ogg rename to data/sound/theme_music_single.ogg diff --git a/resource/sound/you_win.ogg b/data/sound/you_win.ogg similarity index 100% rename from resource/sound/you_win.ogg rename to data/sound/you_win.ogg diff --git a/main.py b/main.py index 394244b..5e544b3 100644 --- a/main.py +++ b/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() \ No newline at end of file + asyncio.run(run_game()) diff --git a/requirements.txt b/requirements.txt index 56e05c1..2e4af92 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/resource/sound/option_change.wav b/resource/sound/option_change.wav deleted file mode 100644 index 5e74ae1..0000000 Binary files a/resource/sound/option_change.wav and /dev/null differ diff --git a/tetri5/game.py b/tetri5/game.py index af2d92c..9b4ec48 100644 --- a/tetri5/game.py +++ b/tetri5/game.py @@ -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: diff --git a/tetri5/online.py b/tetri5/online.py index d9b804f..07fedfa 100644 --- a/tetri5/online.py +++ b/tetri5/online.py @@ -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 diff --git a/tetri5/util.py b/tetri5/util.py index fc4747b..13461c4 100644 --- a/tetri5/util.py +++ b/tetri5/util.py @@ -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