Coder Social home page Coder Social logo

sraakesh95github / react-native-tictactoe Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pubnubdevelopers/react-native-tictactoe

0.0 0.0 0.0 750 KB

Realtime tic tac toe game in React Native powered by PubNub

Home Page: https://www.pubnub.com/blog/multiplayer-mobile-tic-tac-toe-react-native-ios-android-part-one/

Shell 0.83% JavaScript 68.94% Objective-C 16.04% Java 6.17% Starlark 8.03%

react-native-tictactoe's Introduction

Realtime Tic Tac Toe Game in React Native

⚠️ This tutorial is out of date: While some information may not be completely up to date, this repository still contains some useful insights into developing a React Native application. You can learn more about how PubNub powers thousands of customers worldwide in our PubNub for Developers resources. Have suggestions or questions about the content of this post? Reach out to [email protected].

A React Native game that lets players play Tic Tac Toe against each other in this classic childhood game. Any moves the player makes will be seen in realtime by the other player, no matter where they are in the world! PubNub's React SDK is used to power the realtime infrastructure of the game and to provide a connected shared experience for the players.

ios/android screenshot of the game

Setup

  1. To get started, create your PubNub account to get your Pub/Sub API Keys.
  2. You need to enable presence to detect the number of people in the game channel, which prevents having more than two people in a game. To do so, go to your PubNub Admin Dashboard, click on the Demo Project App, or create a new app for this project, and click on Keyset. Scroll down to Application add-ons and toggle the Presence switch to on. Keep the default values the same.

Enable Presence add-on

  1. Clone the repo.
git clone https://github.com/PubNubDevelopers/react-native-tictactoe.git
  1. Open the project in your favorite text editor, such as VS Code or Notepad++

  2. Go to App.js and replace 'ENTER_YOUR_PUBLISH_KEY_HERE' and 'ENTER_YOUR_SUBSCRIBE_KEY_HERE' with the keys you got from Step 1.

  3. You need to install the dependencies and link them to the app. You can do this by running the script that's in the root directory. Make sure to make the script executable first.

#dependencies.sh
chmod +x dependencies.sh # Execute the script
./dependencies.sh # Run the script
  1. Type the following command to run the app in the simulator:
react-native run-ios
  • You can also run the app in the emulator, but make sure to have the emulator opened first:
react-native run-android
  1. To test the app without having to open up another simulator/emulator, you can use the React version of this tic-tac-toe app. The React app is already connected to the React Native app and is ready to play. To get started, clone the React App from the repo.
    git clone https://github.com/PubNubDevelopers/react-tutorial-tic-tac-toe.git
    • Once you open the project, go to the file Game.js and in the constructor, add the same Pub/Sub keys you used for the React Native app. After, type the following command in the terminal to install the dependencies:
    npm install
    • To run the app, type the following in the terminal:
    npm run
    • The app will open in http://localhost:3000 with an empty table and two input fields. The React app will be used to join a channel (Note: The React app is currently set up to only join channels and not create them) and the simulator/emulator will be used to create a room channel.

Build Your Own Realtime Tic Tac Toe Game in React Native

To learn more about this project or if you want to build this project from scratch, check out the tutorial.

react-native-tictactoe's People

Contributors

oliverfcarson 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.