Skip to content

Commit

Permalink
woopoooh
Browse files Browse the repository at this point in the history
  • Loading branch information
quasar098 committed Dec 16, 2022
1 parent 3b208c0 commit f35f4c7
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.idea
*.iml
__pycache__
.vscode
.vscode
build
dist
.exe
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,25 @@ this depends on difficulty
- normal starts with 3 free slots
- easy starts with all 4 free slots

you can unlock free slots by making complete stacks by themselves
you can unlock free slots by making complete stacks (4 of the same) by themselves
in the bottom 8 slots (not the top 4)

### build instructions:

1) Install the necessary python packages with `pip install -r requirements.txt`
2) Check that it runs from source by running the main.py file
3) Install PyInstaller module
4) Navigate in cmd or bash to the root directory of this project
5) Run `PyInstaller main.py --clean --onefile --noconsole --add-data "./assets;assets"`
**NOTE:** you need to replace the ; with : on unix systems


#### build command explained:

The `--clean` part of the build command helps the executable be not flagged as a virus by Windows Defender

The `--onefile` makes it all one file instead of a dll nightmare

The `--noconsole` starts the pygame window without a console alongside it

The `--add-data` part takes the assets folder and bundles it with the executable
1 change: 1 addition & 0 deletions assetloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AssetLoader:
darken = None

muted = False
running = False

@staticmethod
def play_sound(sound: pygame.mixer.Sound, volume=0.3, loop=False):
Expand Down
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
from utils import *
from game import Game

# build help for adding assets: https://python.plainenglish.io/packaging-data-files-to-pyinstaller-binaries-6ed63aa20538

pygame.init()
screen = pygame.display.set_mode([WIDTH, HEIGHT], pygame.NOFRAME)

loading_image = pygame.image.load(join(getcwd(), "images", "loading.png")).convert_alpha()
loading_image = pygame.image.load(join(dirname(__file__), "assets", "loading.png")).convert_alpha()
screen.blit(loading_image, loading_image.get_rect(center=screen.get_rect().center))
pygame.mouse.set_cursor(pygame.SYSTEM_CURSOR_WAIT)

Expand Down
40 changes: 40 additions & 0 deletions main.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- mode: python ; coding: utf-8 -*-


block_cipher = None


a = Analysis(['main.py'],
pathex=[],
binaries=[],
datas=[('./assets', 'assets')],
hiddenimports=[],
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='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None )
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pygame==2.0.1
4 changes: 3 additions & 1 deletion titlebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from utils import *
from assetloader import AssetLoader
from board import Board
from sys import exit
from diffselect import DifficultySelector


Expand Down Expand Up @@ -51,9 +52,10 @@ def handle_event(self, event: pygame.event.Event):
pygame.display.iconify()
if mute_rect.collidepoint(mp()):
AssetLoader.muted = not AssetLoader.muted
AssetLoader.play_sound(AssetLoader.select_sound)
if refresh_rect.collidepoint(mp()):
DifficultySelector.instance.shown = True
AssetLoader.play_sound(AssetLoader.select_sound)
if close_rect.collidepoint(mp()):
pygame.quit()
quit()
exit()
7 changes: 3 additions & 4 deletions utils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import pygame
from os import getcwd
from os.path import join
from os.path import join, dirname


def load_image(img_name: str):
return pygame.image.load(join(getcwd(), "assets", img_name)).convert_alpha()
return pygame.image.load(join(dirname(__file__), "assets", img_name)).convert_alpha()


def load_sound(sound_name: str):
return pygame.mixer.Sound(join(getcwd(), "assets", sound_name))
return pygame.mixer.Sound(join(dirname(__file__), "assets", sound_name))


def mp():
Expand Down

0 comments on commit f35f4c7

Please sign in to comment.