← Back to Projects
Android Application Mobile Game Declarative UI Game Logic

Tic-Tac-Toe — Play and Have Fun

An interactive Android game featuring a game board, different screens, game modes, and result handling. Built to practise Kotlin, declarative UI design, and Android app development.

tictactoe.app
❌
Tic-Tac-Toe

An interactive Android game with multiple screens, game modes, and result handling.

Tech Stack

Languages

Kotlin

Mobile Development

Jetpack Compose Android Studio

Tools and Workflow

Git GitHub

🚀 Overview

Tic-Tac-Toe — Play and Have Fun is an interactive Android game developed with Kotlin and Jetpack Compose. The project was built as a hands-on exercise to practise modern Android development, declarative UI design, and game logic implementation. It features a clean game board, multiple screens, different game modes, and proper handling of game results.

Built entirely with Jetpack Compose, the app demonstrates a declarative approach to building Android UIs. State management drives the game flow—from the start screen through gameplay to the result screen—making the code predictable and easy to follow. The game supports both player-versus-player and other modes, with win, lose, and draw conditions handled cleanly.

✨ Key Features

  • Interactive Game Board: A responsive 3×3 grid where players tap cells to place their marks (X or O).
  • Multiple Screens: Distinct screens for the start menu, gameplay, and results, managed through navigation.
  • Game Modes: Different game modes to choose from, adding variety to the experience.
  • Result Handling: Clear detection and display of win, loss, and draw outcomes with appropriate messaging.
  • Declarative UI: Built entirely with Jetpack Compose for a modern, reactive user interface.
  • State Management: Game state is managed reactively so the UI updates instantly as the game progresses.
  • Turn Indication: Visual feedback showing whose turn it is during gameplay.
  • Restart Functionality: Players can quickly start a new game without restarting the app.

💡 Technical Challenges

Challenge 1: Managing Game State Reactively

Problem: A tic-tac-toe game requires the UI to update immediately every time a player makes a move. Without proper state management, the board can become inconsistent with the underlying game logic.

Solution: Used Jetpack Compose's state management to hold the board state as observable state. Each move updates the state, triggering automatic recomposition of the board UI. This keeps the displayed board perfectly in sync with the game logic.

Challenge 2: Implementing Win Detection Logic

Problem: Detecting a win or draw correctly requires checking all possible winning combinations (rows, columns, diagonals) after every move, while avoiding false positives and handling the draw condition.

Solution: Implemented a dedicated function that checks all eight winning lines after each move. If a line is fully occupied by the same player, a win is declared. If the board is full with no winner, a draw is declared. The result is then reflected in the UI.

Challenge 3: Navigating Between Multiple Screens

Problem: The app has multiple screens (start, game, result), and moving between them while preserving or resetting game state can be tricky in a declarative UI framework.

Solution: Used Jetpack Compose Navigation to define routes for each screen. Game state is scoped appropriately so that starting a new game resets the board, while navigating back to the menu retains a clean starting point. This gives a smooth, intuitive flow.

📈 Outcome / Lessons Learned

Architecture & Engineering Excellence

  • Kotlin & Jetpack Compose: Strengthened Kotlin skills and gained practical experience building a complete app with declarative UI.
  • State-Driven UI: Learned to think in terms of state and recomposition rather than imperative UI updates.
  • Game Logic: Practiced implementing clean, testable game logic for win/draw detection and turn management.

Product Impact

  • Fun & Engaging: Delivered a polished, interactive game that is enjoyable to play.
  • Clear Feedback: Players always know whose turn it is and receive immediate results when the game ends.
  • Smooth Flow: Intuitive navigation between menu, gameplay, and results makes the app easy to use.

Real-World Learning

  • Declarative UI Paradigm: Understood how Jetpack Compose simplifies UI development through composition and state.
  • State Management: Learned that well-managed state is the foundation of a bug-free, reactive app.
  • Mobile App Workflow: Experienced the full cycle of building, testing, and refining an Android app in Android Studio.