Skip to content

Tetris game written in Kotlin Multiplatform (KMP) and Compose Multiplatform for Android, Desktop, Web, and SwiftUI for iOS and mac

Notifications You must be signed in to change notification settings

yet300/TetrisLite

Repository files navigation

TetrisLite

258

A modern, cross-platform Tetris game built with Kotlin Multiplatform and Compose Multiplatform, demonstrating true code sharing across Android, iOS, Desktop, and Web platforms.

Kotlin Compose Platforms

Features

🎨 Customization

  • Visual Themes - 9 color schemes: Classic, Modern, Neon, Retro, Pastel, Dark, Monochrome, Cyberpunk, and Nature
  • Piece Styles - Choose between Solid, Gradient, and Outlined piece rendering
  • Audio Settings - Procedurally generated music and SFX with volume control and multiple themes

πŸ“± Platform-Specific Features

  • Android - Touch controls with swipe gestures, baseline profiles for performance
  • iOS - Native SwiftUI integration with iOS-specific optimizations
  • Desktop - Keyboard controls that feel great on Windows, macOS, and Linux
  • Web (Compose) - Browser-based gameplay with Kotlin/JS and Compose for Web
  • Web (Kotlin/JS + React) - Kotlin/JS with React wrappers for type-safe web development

πŸ’Ύ Technical Features

  • Game History - Track all your games with detailed statistics and filtering
  • Persistent Settings - Your preferences are saved across sessions
  • Offline Support - Play without an internet connection
  • SQLite Database - Local storage for game records and settings
  • Procedural Audio - Dynamically generated music and SFX (no audio files needed!)
  • MVI Architecture - Predictable state management with MVIKotlin
  • Dependency Injection - Koin for clean architecture

Tech Stack

  • Kotlin Multiplatform 2.2.20 - Share code across all platforms
  • Compose Multiplatform 1.9.0 - Modern declarative UI
  • MVIKotlin - MVI architecture for predictable state management
  • Decompose - Navigation and lifecycle management
  • Koin - Dependency injection
  • SQLDelight - Type-safe SQL database
  • Kotlinx Coroutines - Asynchronous programming
  • Kotlinx Serialization - JSON serialization

Architecture

The project follows clean architecture principles with clear separation of concerns:

TetrisLite/
β”œβ”€β”€ composeApp/          # Compose Multiplatform UI (Android, Desktop, Web)
β”œβ”€β”€ iosApp/              # Native iOS app entry point with SwiftUI
β”œβ”€β”€ webApp/              # Kotlin/JS + React wrappers web app
β”œβ”€β”€ shared/              # Shared business logic and data layer
β”œβ”€β”€ core/                # Core modules
β”‚   β”œβ”€β”€ domain/          # Business logic, use cases, domain models
β”‚   β”œβ”€β”€ data/            # Repository implementations
β”‚   β”œβ”€β”€ database/        # SQLDelight database
β”‚   β”œβ”€β”€ common/          # Common utilities
β”‚   └── uikit/           # Shared UI components
└── feature/             # Feature modules
    β”œβ”€β”€ game/            # Game screen and logic
    β”œβ”€β”€ home/            # Home screen
    β”œβ”€β”€ settings/        # Settings management
    β”œβ”€β”€ history/         # Game history
    └── root/            # Navigation root

Getting Started

Prerequisites

  • JDK 17 or higher
  • Android Studio Ladybug or later (for Android development)
  • Xcode 15+ (for iOS development, macOS only)
  • Node.js (for web development)

Build and Run

Android

./gradlew :composeApp:assembleDebug
./gradlew :composeApp:installDebug

Desktop (JVM)

./gradlew :composeApp:run

iOS

Open iosApp/iosApp.xcodeproj in Xcode and run the project.

Web (Compose)

./gradlew :composeApp:jsBrowserDevelopment

Web (Kotlin/JS + React)

./gradlew :webApp:jsBrowserDevelopmentRun

Development

Code Style

The project uses Ktlint for code formatting and Detekt for static analysis.

./gradlew ktlintCheck
./gradlew detekt

Testing

./gradlew test

CI/CD

The project includes GitHub Actions workflows for:

  • PR Checks - Code quality, tests, and builds
  • Release - Automated builds and deployments
  • Code Quality - Static analysis and linting

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Key areas for enhancement:

  1. UI/UX: Improve the iOS part

License

This project is open source and available under the MIT License.

Learn More

About

Tetris game written in Kotlin Multiplatform (KMP) and Compose Multiplatform for Android, Desktop, Web, and SwiftUI for iOS and mac

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages