A modern implementation of the classic 2048 puzzle game, built with Kotlin and Jetbrains Compose for Desktop. This project demonstrates clean architecture principles and modern development practices in Kotlin.
- 🎮 Classic 2048 gameplay mechanics
- 🎨 Modern UI with Material 3 design
- ⌨️ Keyboard controls (Arrow keys or WASD)
- 🎯 Score tracking and game state management
- 💾 Game state persistence
- 🖼️ Smooth animations and transitions
- 📱 Responsive layout
- Language: Kotlin 1.9.20
- UI Framework: Jetbrains Compose for Desktop with Material 3
- Async Operations: Kotlin Coroutines
- Testing:
- JUnit 5
- Mockk for mocking
- Coroutines Test
- Kover for code coverage
- Code Quality:
- ktlint for code formatting
- detekt for static code analysis
- JDK 21 or later
- Gradle 8.0 or later
-
Clone the repository:
git clone https://github.com/yourusername/2048.git cd 2048
-
Build the project:
./gradlew build
-
Run the application:
./gradlew run
- Use arrow keys or WASD to move tiles
- When two tiles with the same number touch, they merge into one
- After each move, a new tile appears in a random empty spot
- Create a tile with the number 2048 to win!
- If you can't make a move, the game is over
This project follows clean architecture principles and Kotlin best practices. The codebase is organized into several key components:
- Core Game Logic: Handles game rules and mechanics
- Game Engine: Manages game state and processes moves
- UI Layer: Implements the user interface using Compose
- Domain Models: Defines the game's data structures
Run the tests with:
./gradlew test
This will also generate a code coverage report in the build/reports/kover/html
directory.
The project uses several tools to maintain code quality:
- Run ktlint:
./gradlew ktlintCheck
- Run detekt:
./gradlew detekt
This project is licensed under the MIT License - see the LICENSE file for details.