Skip to content

Commit

Permalink
Configured the main.py to run with pygbag.
Browse files Browse the repository at this point in the history
  • Loading branch information
memo1918 committed Dec 5, 2024
1 parent 6cbb621 commit 89d2f1c
Show file tree
Hide file tree
Showing 6 changed files with 513 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/__pycache__/
.vscode/launch.json
build/web-cache/
49 changes: 22 additions & 27 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
from Classes.Board import Board
from Classes.Button import Button
from Classes.Computer import Computer
import sys,getopt
import sys
import asyncio

def play(turn: str) -> None:
async def play(turn: str) -> None:
"""
Function that runs the game.
Expand Down Expand Up @@ -34,8 +35,8 @@ def play(turn: str) -> None:
board.click(mx,my)
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
main_menu()
break
await main_menu()
return

if board.turn == True:
board.computerMove(computer)
Expand All @@ -46,10 +47,11 @@ def play(turn: str) -> None:

result =board.isWin()
if result != False:
winScreen(result)
break
await winScreen(result)
return
await asyncio.sleep(0)

def winScreen(text) -> None:
async def winScreen(text) -> None:
"""
Runs the Win Screen
Expand Down Expand Up @@ -79,11 +81,12 @@ def winScreen(text) -> None:

if event.type == pygame.MOUSEBUTTONDOWN:
if back_button.checkForInput(mouse_pos):
main_menu()
break
await main_menu()
return
pygame.display.update()
await asyncio.sleep(0)

def about() -> None:
async def about() -> None:
"""
Function that runs about/how to play page
"""
Expand Down Expand Up @@ -139,11 +142,12 @@ def text_seperator(text: str, x: int, y: int )-> list:
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if back_button.checkForInput(mouse_pos):
main_menu()
break
await main_menu()
return
pygame.display.update()
await asyncio.sleep(0)

def main_menu() -> None:
async def main_menu() -> None:
"""
Function that runs Main Menu.
"""
Expand Down Expand Up @@ -173,16 +177,17 @@ def main_menu() -> None:
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if first_button.checkForInput(mouse_pos):
play("first")
await play("first")
if second_button.checkForInput(mouse_pos):
play("second")
await play("second")
if about_button.checkForInput(mouse_pos):
about()
await about()
if quit_button.checkForInput(mouse_pos):
pygame.quit()
sys.exit()

pygame.display.update()
await asyncio.sleep(0)


if __name__ == "__main__":
Expand All @@ -191,16 +196,6 @@ def main_menu() -> None:
size = 6
depth = 3

argv = sys.argv[1:]
opts, args = getopt.getopt(argv, "r:s:d:", ["resolution =","size =","depth ="])
for opt, arg in opts:
if opt in ['-r','--resolution']:
resolution = int(arg)
if opt in ['-s','--size']:
size = int(arg) if int(arg)>3 else 6
if opt in ['-d','--depth']:
depth = int(arg) if int(arg)>0 else 3

centerY = resolution//2 #gets the center Y value
spacesX = resolution//6 #gets the optimal spaces between buttons
fontSize = resolution//18
Expand All @@ -210,4 +205,4 @@ def main_menu() -> None:
screen = pygame.display.set_mode((resolution, resolution))
font = pygame.font.SysFont("arialblack", fontSize)

main_menu()
asyncio.run(main_menu())
1 change: 1 addition & 0 deletions build/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.9.2
Binary file added build/web/breakthrough-board-game.apk
Binary file not shown.
Binary file added build/web/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 89d2f1c

Please sign in to comment.