Giter Site home page Giter Site logo

trishna456 / tic-tac-toe Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 295 KB

This is a tic-tac-toe game built using React. It allows two players to take turns marking spaces in a 3x3 grid, aiming to get three of their symbols in a row, column, or diagonal.

Home Page: https://tic-tac-toe-trishna.netlify.app/

HTML 3.73% JavaScript 51.87% CSS 44.40%
state-management-in-react component-modularity game-play-logic prop-derivation

tic-tac-toe's Introduction

React Tic-Tac-Toe

This is a simple tic-tac-toe game built using React. It allows two players to take turns marking spaces in a 3x3 grid, aiming to get three of their symbols in a row, column, or diagonal.

Features

  • Two-player functionality: Players can take turns marking spaces on the board.
  • Player customization: Each player can set their name and choose their symbol (e.g., "X" or "O").
  • Edit player names: Players can edit their names during the game.
  • Game log: Keeps track of each turn, displaying the player's name and the selected square.
  • Game board: Renders the 3x3 grid where players can select empty squares to make their moves.
  • Game over screen: Displays a message when the game ends, indicating the winner or if it's a draw.
  • Responsive design: The game interface adjusts to different screen sizes for a seamless experience on desktop and mobile devices.

Key Concepts and Implementation:

  • Component Modularity: I split components and built reusable components to ensure a clean and maintainable codebase, following the principle of component reusability.
  • State Management: Employed React's state management capabilities effectively, including working with state, updating state based on old state correctly, and avoiding intersecting states to ensure optimal performance and scalability.
  • Optimized State Management: Applied best practices to reduce state management overhead, such as preferring computed values over unnecessary state management and deriving state from props when appropriate.
  • Sharing State Across Components: Utilized techniques to share state across components efficiently, enhancing code readability and reducing redundancy.
  • Gameplay Logic: Implemented essential gameplay features such as tracking game progress, determining the winner, handling game over scenarios, and checking for draws, providing players with a seamless and immersive gaming experience.

Getting Started

To run this tic-tac-toe game locally, follow these steps:

  1. Clone this repository to your local machine:
git clone https://github.com/your-username/react-tic-tac-toe.git
  1. Navigate to the project directory:
cd react-tic-tac-toe
  1. Install dependencies using npm or yarn:
npm install
# or
yarn install
  1. Start the development server:
npm start
# or
yarn start
  1. Open your web browser and navigate to http://localhost:3000 to view the tic-tac-toe game.

How to Play

Players take turns clicking on empty squares to mark them with their symbol. The first player to get three of their symbols in a row, column, or diagonal wins the game. If all squares are filled and no player has won, the game ends in a draw.

Customization

You can customize the players' names and symbols by editing the Player component in the Player.js file.

Game Log

The Log component keeps track of each turn during the game. It displays the player's name and the selected square.

Game Board

The GameBoard component renders the 3x3 grid where players can select empty squares to make their moves.

Game Over Screen

The GameOver component displays a message when the game ends, indicating the winner or if it's a draw.

Contributing

Contributions to this project are welcome! If you find any bugs or have suggestions for improvements, please open an issue or submit a pull request.

tic-tac-toe's People

Contributors

trishna456 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.