Initial release: SDL Windows Tetris

This commit is contained in:
2025-08-15 11:01:48 +02:00
commit d161b2c550
196 changed files with 5944 additions and 0 deletions

146
package-quick.ps1 Normal file
View File

@ -0,0 +1,146 @@
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Quick Production Package Creator for Tetris SDL3
.DESCRIPTION
This script creates a production package using the existing build-msvc directory.
Useful when you already have a working build and just want to create a distribution package.
#>
param(
[string]$OutputDir = "dist"
)
$ProjectName = "tetris"
$PackageDir = Join-Path $OutputDir "TetrisGame"
$Version = Get-Date -Format "yyyy.MM.dd"
function Write-ColorOutput($ForegroundColor) {
$fc = $host.UI.RawUI.ForegroundColor
$host.UI.RawUI.ForegroundColor = $ForegroundColor
if ($args) { Write-Output $args }
$host.UI.RawUI.ForegroundColor = $fc
}
function Write-Success { Write-ColorOutput Green $args }
function Write-Info { Write-ColorOutput Cyan $args }
function Write-Warning { Write-ColorOutput Yellow $args }
function Write-Error { Write-ColorOutput Red $args }
Write-Info "======================================"
Write-Info " Tetris Quick Package Creator"
Write-Info "======================================"
# Check if build exists
$ExecutablePath = "build-msvc\Debug\tetris.exe"
if (!(Test-Path $ExecutablePath)) {
$ExecutablePath = "build-msvc\Release\tetris.exe"
if (!(Test-Path $ExecutablePath)) {
Write-Error "No executable found in build-msvc directory. Please build the project first."
exit 1
}
}
Write-Success "Found executable: $ExecutablePath"
# Create package directory
if (Test-Path $PackageDir) {
Remove-Item $PackageDir -Recurse -Force
}
New-Item -ItemType Directory -Path $PackageDir -Force | Out-Null
# Copy executable
Copy-Item $ExecutablePath $PackageDir
Write-Success "Copied tetris.exe"
# Copy assets
if (Test-Path "assets") {
Copy-Item "assets" -Destination (Join-Path $PackageDir "assets") -Recurse -Force
Write-Success "Copied assets folder"
}
if (Test-Path "FreeSans.ttf") {
Copy-Item "FreeSans.ttf" $PackageDir
Write-Success "Copied FreeSans.ttf"
}
# Copy DLLs from vcpkg (SDL_image no longer needed)
$VcpkgBin = "vcpkg_installed\x64-windows\bin"
if (Test-Path $VcpkgBin) {
$DllFiles = @("SDL3.dll", "SDL3_ttf.dll")
foreach ($dll in $DllFiles) {
$dllPath = Join-Path $VcpkgBin $dll
if (Test-Path $dllPath) {
Copy-Item $dllPath $PackageDir
Write-Success "Copied $dll"
}
}
}
# Create launcher
$LaunchContent = @"
@echo off
cd /d "%~dp0"
tetris.exe
if %errorlevel% neq 0 (
echo.
echo Game crashed or failed to start!
echo Check that all DLL files are present.
echo.
pause
)
"@
$LaunchContent | Out-File -FilePath (Join-Path $PackageDir "Launch-Tetris.bat") -Encoding ASCII
Write-Success "Created Launch-Tetris.bat"
# Create README
$ReadmeContent = @"
Tetris SDL3 Game
================
## Quick Start
1. Run Launch-Tetris.bat or tetris.exe
2. Use arrow keys to move, Z/X to rotate, Space to drop
3. Press F11 for fullscreen, Esc for menu
## Files
- tetris.exe: Main game
- Launch-Tetris.bat: Safe launcher with error handling
- assets/: Game resources (music, images, fonts)
- *.dll: Required libraries
## Controls
Arrow Keys: Move pieces
Z/X: Rotate pieces
C: Hold piece
Space: Hard drop
P: Pause
F11: Fullscreen
Esc: Menu
Enjoy!
"@
$ReadmeContent | Out-File -FilePath (Join-Path $PackageDir "README.txt") -Encoding UTF8
Write-Success "Created README.txt"
# Calculate size
$PackageSize = (Get-ChildItem $PackageDir -Recurse | Measure-Object -Property Length -Sum).Sum
$PackageSizeMB = [math]::Round($PackageSize / 1MB, 2)
# Create ZIP
$ZipPath = Join-Path $OutputDir "TetrisGame-$Version.zip"
try {
Compress-Archive -Path $PackageDir -DestinationPath $ZipPath -Force
Write-Success "Created ZIP: $ZipPath"
} catch {
Write-Warning "Failed to create ZIP: $($_.Exception.Message)"
}
Write-Info ""
Write-Success "Package created successfully!"
Write-Info "Location: $PackageDir"
Write-Info "Size: $PackageSizeMB MB"
Write-Info "ZIP: $ZipPath"
Write-Info ""
Write-Info "Ready for distribution! 🎮"