GithubHelp home page GithubHelp logo

pong_game_for_backend_socket's Introduction

Multiplay Pong game (with websocket in node.js)

Introduction

This repo show how to implement the multiplayer pong game by Websocket. It use the package of socket.io to achieve the double channel communication and the server is built by node.js and express.

ScreenShot
The screenshot of multiplay pong game

On the server side, it can monitor how many tabs are connected to this URL, and display the room numbers that are paired with each other.

ScreenShot
The record of server side

The thinking of two-way communication

Here are some things that have to notice when developing:

  1. Game ready and start: To confirm two players are paired with each other and the secondary wil be referee to start the game.
  2. The data of paddle moving: The client side always emit his paddle position and the server side will get and broadcast the other one's paddle position.
  3. The data of ball moving: On the client side, it will emit the ball position and get it from the server side immediately.
ScreenShot
The design channel of socket

Installation

  1. Make sure you already environment of node.js and install express

    npm install
    npm install express
  2. Install the package of socket.io

    npm install socket.io
  3. Run the server and open http://localhost:3000 in your browser

    npm run start

Contributor

Wen Su

pong_game_for_backend_socket's People

Contributors

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