Initial release: SDL Windows Tetris
This commit is contained in:
44
.github/copilot-instructions.md
vendored
Normal file
44
.github/copilot-instructions.md
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
# Copilot Instructions — Tetris (C++ SDL3)
|
||||
|
||||
Purpose: Speed up development on this native SDL3 Tetris. Follow these conventions to keep builds reproducible and packages shippable.
|
||||
|
||||
## Project shape
|
||||
- C++20 app using SDL3 + SDL3_ttf via vcpkg.
|
||||
- Build system: CMake; Windows-focused, but portable with proper toolchain.
|
||||
- Sources: `src/` (Game.cpp, Scores.cpp, Starfield*.cpp, Audio.cpp, LineEffect.cpp, Font.cpp, SoundEffect.cpp, main.cpp).
|
||||
- Assets: `assets/` (images/music/fonts), plus `FreeSans.ttf` at repo root.
|
||||
|
||||
## Build and run
|
||||
- Configure and build Release:
|
||||
- CMake picks up vcpkg toolchain if found (`VCPKG_ROOT`, local `vcpkg/`, or user path). Required packages: `sdl3`, `sdl3-ttf` (see `vcpkg.json`).
|
||||
- Typical sequence (PowerShell): `cmake -S . -B build-release -DCMAKE_BUILD_TYPE=Release` then `cmake --build build-release --config Release`.
|
||||
- Packaging: `.\build-production.ps1` creates `dist/TetrisGame/` with exe, DLLs, assets, README, and ZIP; it can clean via `-Clean` and package-only via `-PackageOnly`.
|
||||
- MSVC generator builds are under `build-msvc/` when using Visual Studio.
|
||||
|
||||
## Runtime dependencies
|
||||
- Links: `SDL3::SDL3`, `SDL3_ttf::SDL3_ttf`; on Windows also `mfplat`, `mfreadwrite`, `mfuuid` for media.
|
||||
- The package step copies `SDL3.dll` and `SDL3_ttf.dll` from `vcpkg_installed/x64-windows/bin/` if present. If changing triplet or layout, update paths in `build-production.ps1`.
|
||||
|
||||
## Key modules and responsibilities
|
||||
- Game loop and state: `Game.cpp/h` (core), `main.cpp` (entry), `Scores.cpp/h` (high-scores/local), `LineEffect.cpp` (row clear visuals), `Starfield.cpp` and `Starfield3D.cpp` (background effects), `Audio.cpp` + `SoundEffect.cpp` (music/SFX), `Font.cpp` (TTF text rendering).
|
||||
- Keep drawing and update timing consistent; prefer updating effects modules rather than inlining in `Game.cpp`.
|
||||
|
||||
## Assets and fonts
|
||||
- Expect `assets/` folder adjacent to the executable; `FreeSans.ttf` is copied next to the exe by packaging scripts.
|
||||
- When adding assets, ensure packaging script includes new folders/files; use BMP/PNG consistently with existing loaders.
|
||||
|
||||
## Conventions
|
||||
- C++20, no exceptions policy not enforced; match current code style in each file.
|
||||
- Use SDL_ttf for text; don’t vendor fonts in code—load from filesystem as done in `Font.cpp`.
|
||||
- Avoid hardcoding absolute paths; rely on relative paths within the package layout.
|
||||
|
||||
## Useful files
|
||||
- `CMakeLists.txt` — targets, toolchain detection, link libs.
|
||||
- `vcpkg.json` and `vcpkg-configuration.json` — dependencies and registry.
|
||||
- `build-production.ps1` — authoritative packaging steps and expected layout.
|
||||
- `cmake/ProductionBuild.cmake` — extra flags if needed (included by `CMakeLists.txt`).
|
||||
|
||||
## When extending
|
||||
- Add new modules under `src/` and register them in `CMakeLists.txt` target sources.
|
||||
- If new DLLs are required, extend the copy list in `build-production.ps1` and document them in the generated README.
|
||||
- Validate with a Release build before packaging to catch optimizer-related issues.
|
||||
114
.github/workflows/build.yml
vendored
Normal file
114
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
name: Build and Package Tetris
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master ]
|
||||
tags: [ 'v*' ]
|
||||
pull_request:
|
||||
branches: [ main, master ]
|
||||
|
||||
jobs:
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup vcpkg
|
||||
uses: lukka/run-vcpkg@v11
|
||||
with:
|
||||
vcpkgGitCommitId: 'latest'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
vcpkg install sdl3 sdl3-image sdl3-ttf --triplet=x64-windows
|
||||
|
||||
- name: Configure CMake
|
||||
run: |
|
||||
cmake -B build -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
- name: Build
|
||||
run: cmake --build build --config Release
|
||||
|
||||
- name: Package
|
||||
run: cmake --build build --target package
|
||||
|
||||
- name: Create distribution package
|
||||
run: |
|
||||
mkdir dist
|
||||
powershell -ExecutionPolicy Bypass -File build-production.ps1 -PackageOnly -OutputDir dist
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tetris-windows-x64
|
||||
path: dist/TetrisGame/
|
||||
|
||||
- name: Create Release ZIP
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: |
|
||||
cd dist
|
||||
7z a ../TetrisGame-Windows-x64.zip TetrisGame/
|
||||
|
||||
- name: Release
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: TetrisGame-Windows-x64.zip
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
build-linux:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y cmake build-essential
|
||||
# Install SDL3 from source or package manager
|
||||
# This may need adjustment based on SDL3 availability
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
- name: Build
|
||||
run: cmake --build build
|
||||
|
||||
- name: Package
|
||||
run: |
|
||||
mkdir -p dist/TetrisGame-Linux
|
||||
cp build/tetris dist/TetrisGame-Linux/
|
||||
cp -r assets dist/TetrisGame-Linux/
|
||||
cp FreeSans.ttf dist/TetrisGame-Linux/
|
||||
echo '#!/bin/bash' > dist/TetrisGame-Linux/launch-tetris.sh
|
||||
echo 'cd "$(dirname "$0")"' >> dist/TetrisGame-Linux/launch-tetris.sh
|
||||
echo './tetris' >> dist/TetrisGame-Linux/launch-tetris.sh
|
||||
chmod +x dist/TetrisGame-Linux/launch-tetris.sh
|
||||
chmod +x dist/TetrisGame-Linux/tetris
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: tetris-linux-x64
|
||||
path: dist/TetrisGame-Linux/
|
||||
|
||||
- name: Create Release TAR
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: |
|
||||
cd dist
|
||||
tar -czf ../TetrisGame-Linux-x64.tar.gz TetrisGame-Linux/
|
||||
|
||||
- name: Release
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: TetrisGame-Linux-x64.tar.gz
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
Reference in New Issue
Block a user