Skip to content
AlinaStepanovaPublic

About

A simple, tiny (< 1 MB size) Sea Battle 2D-game. Custom Views, Canvas. Kotlin, Coroutines, CI with Github Actions, units tests.

Resources

Stars

12 stars

Watchers

1 watching

Forks

Repository files navigation

SeaBattle

Sea Battle - a classic Battleship 2D game for Android, written in Kotlin with Jetpack Compose and Coroutines.

push

Play Market 50K+ downloads

How to play

Features

  • Hand-drawn notebook look with light and dark themes
  • Portrait and landscape layouts
  • Computer opponent that hunts down wounded ships
  • English, Ukrainian and Russian localization

Active branches:

    dev - contains stable implementation of main functionality and tests.
    master - released versions.

Architecture approach

Single-Activity MVVM. MainViewModel owns the game state and exposes it as a single StateFlow<GameUiState>; the Compose UI observes it and draws both boards on Canvas.

  • battle_field - pure Kotlin game model: the 10×10 grid, ship placement and shot handling
  • main - MainViewModel runs the turns, ShotManager is the computer's AI
  • ui - Compose screens, the notebook-paper background and the board grid

Main libraries used:

Jetpack Compose, Material 3 - UI
Coroutines, StateFlow - pacing the computer's moves and delivering state to the UI
Lifecycle ViewModel - keeping game state across configuration changes
Play In-App Review - asking for a rating after a win
JUnit 4, Mockito, Compose UI Test - tests

Build

./gradlew assembleDebug        # build debug APK
./gradlew testDebugUnitTest    # unit tests
./gradlew connectedAndroidTest # instrumented tests (device/emulator)

About

A simple, tiny (< 1 MB size) Sea Battle 2D-game. Custom Views, Canvas. Kotlin, Coroutines, CI with Github Actions, units tests.

Resources

Stars

12 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages