Add pc/ — PyInstaller build scripts, .ico icon, and README

This commit is contained in:
KansaiGaijin
2026-07-07 13:25:27 +12:00
parent 262292228e
commit 1893073af0
5 changed files with 102 additions and 0 deletions

28
pc/README.md Normal file
View File

@@ -0,0 +1,28 @@
# pc/ — Kanjin Windows Standalone
Build a single `.exe` that players can double-click to play — no Python, no IDE, no dependencies.
## Build it
```batch
cd pc
build.bat
```
Deliver `pc\Kanjin.exe` (~35 MB). The player double-clicks it, a console window opens, the game starts.
## What's inside
| File | Purpose |
|---|---|
| `build.bat` | Windows batch script — runs PyInstaller with the right flags |
| `build.sh` | Linux/macOS equivalent (for cross-builds) |
| `kanjin.ico` | Application icon embedded in the .exe |
| `generate_icon.py` | Creates `kanjin.ico` from a solid-colour PNG (run once) |
## Requirements
- Python 3.11+ installed on the **build** machine
- `pip install pyinstaller` (installed automatically by build.bat)
The **player's** machine needs nothing — the .exe is fully self-contained.

20
pc/build.bat Normal file
View File

@@ -0,0 +1,20 @@
@echo off
cd /d "%~dp0"
echo Installing PyInstaller...
pip install pyinstaller
echo Building Kanjin.exe...
REM --onefile: single executable
REM --name: output filename
REM --icon: application icon
REM --distpath=. : place .exe in this directory (pc/)
REM --workpath: temp build folder (cleaned up)
python -m PyInstaller --onefile --name Kanjin --icon=kanjin.ico --distpath=. --workpath=build_temp ..\main.py
echo Cleaning up...
rd /s /q build_temp __pycache__ 2>nul
del Kanjin.spec 2>nul
echo.
echo Done! Deliver pc\Kanjin.exe to players.
pause

19
pc/build.sh Normal file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Cross-platform PyInstaller build (run from pc/ on any OS)
set -euo pipefail
cd "$(dirname "$0")"
pip install pyinstaller
python -m PyInstaller \
--onefile \
--name Kanjin \
--icon=kanjin.ico \
--distpath=. \
--workpath=build_temp \
../main.py
rm -rf build_temp __pycache__ Kanjin.spec
echo ""
echo "Done! Deliver pc/Kanjin.exe to players."

35
pc/generate_icon.py Normal file
View File

@@ -0,0 +1,35 @@
"""Generate kanjin.ico from a solid-colour PNG embedded in an ICO container."""
import struct
import zlib
from pathlib import Path
def _png_chunk(chunk_type, data):
c = chunk_type + data
crc = struct.pack(">I", zlib.crc32(c) & 0xFFFFFFFF)
return struct.pack(">I", len(data)) + c + crc
def solid_png_bytes(width, height, r, g, b):
header = b"\x89PNG\r\n\x1a\n"
ihdr = _png_chunk(b"IHDR", struct.pack(">IIBBBBB", width, height, 8, 2, 0, 0, 0))
raw = bytearray()
for _ in range(height):
raw.append(0)
raw.extend(bytes([r, g, b]) * width)
idat = _png_chunk(b"IDAT", zlib.compress(bytes(raw)))
iend = _png_chunk(b"IEND", b"")
return header + ihdr + idat + iend
def make_ico(png_data):
header = struct.pack("<HHH", 0, 1, 1)
entry = struct.pack("<BBBBHHII", 0, 0, 0, 0, 1, 32, len(png_data), 22)
return header + entry + png_data
if __name__ == "__main__":
dst = Path(__file__).parent / "kanjin.ico"
png = solid_png_bytes(256, 256, 0x1A, 0x1A, 0x2E)
dst.write_bytes(make_ico(png))
print(f"Created {dst.name}")

BIN
pc/kanjin.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B