• This repository has been archived on 08/Jul/2019
  • Stars
    star
    176
  • Rank 216,987 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NodeJS Online Game Template

Barebone NodeJS project for any multiplayer games.


UPDATE: I developed a lightweight alternative for Socket.IO, based on Engine.IO, the engine behind Socket.IO as well. It focus on transmiting binary data instead of string-based as in Socket.IO, so the target is to improve the networking performance. Unfortunatelly, I didn't have time for testing/integrating it yet. It would be nice if somebody can help me integrate it with this repo? Feel free to contact me for further discussion. Thank you so much!


Requirements

  • NodeJS / NPM
  • Socket.IO
  • ExpressJS

Getting started

  • Clone the source code from Github
  • Run npm install to install needed packages
  • Writing your code in server/server.js and client/js/game.js
  • Run your game server with npm start command

Server side

You can write all the server side code in server/server.js

io.on('connection', function (socket) {
  console.log("Somebody connected!");
  // Write your code here
});

Client side

For writing client side code, find client/js/game.js

There are 3 method to process your client logic: handleNetwork, handleLogic and handleGraphics

handleNetwork is where you receive and process all messages sent from Server:

Game.prototype.handleNetwork = function(socket) {
  console.log('Game connection process here');
  console.log(socket);
  // This is where you receive all socket messages
}

The socket is the connection object of your game client, use this to communicate with the server.

handleLogic is where you update your game logic (handling input, update game information,...)

Game.prototype.handleLogic = function() {
  console.log('Game is running');
  // This is where you update your game logic
}

handleGraphics is where you draw your game:

Game.prototype.handleGraphics = function(gfx) {
  // This is where you draw everything
}

License

This project is licensed under the terms of the MIT license. You can read the full license in LICENSE.md

More Repositories

1

kanban-app

Kanban board built with Rust and Elm
Rust
1,774
star
2

pomoday-v2

A keyboard only task management web app
TypeScript
585
star
3

swift-http

HTTP Implementation for Swift on Linux and Mac OS X
Swift
449
star
4

kanelm

Kanban board built with Elm
Elm
296
star
5

ascii-d

A cross-platform ASCII diagram drawing app https://web.ascii-draw.com
Rust
268
star
6

goxkey

Bộ gõ tiếng Việt không có chức năng gì ngoài gõ tiếng Việt...
Rust
239
star
7

azeroth-js

🍺 Yet another Static blog engine. Built with ❤️ for Github
CSS
215
star
8

playgo

👻 a real playful Golang Playground
Go
184
star
9

sequencegenius

Transform your idea to diagrams. With AI, of course, it's 2023. https://sequencegenius.com/
TypeScript
124
star
10

dev.env

👻 Zero Setup Development Environment without Docker or Vagrant
Shell
116
star
11

node-js-game-server

Easy to use Multiplayer Game Server based on Node.JS. Suitable with HTML5 Websocket, Unity3D (Web/PC, Android, iOS,...), Flash, C++/OpenGL/DirectX, XNA clients,...
JavaScript
104
star
12

haskplex-font

103
star
13

js-playground

A JS playground with some decent visualization
TypeScript
99
star
14

codedaily-v3

Rust
87
star
15

vim-config

Vim Script
84
star
16

rust-webapp-template

Template project for Rust web app
Rust
67
star
17

ristretto-rs

☕️ the absolute perfect espresso
CSS
63
star
18

taskedit

📝 an online notepad that only support markdown... lol
JavaScript
59
star
19

lichess-tv

Watch live chess from your terminal
C
57
star
20

hackernews-rss-reader

Read HackerNews's RSS feed
Rust
55
star
21

stackoverlazy

StackOverflow in your terminal
Go
54
star
22

everyday

Trying to write about what I learned everyday
JavaScript
54
star
23

code-playground

An online code playground that supports C++, Python, JavaScript and Rust
TypeScript
50
star
24

OctoCmd

🐙 Do more on Mac, efficiently!
Swift
47
star
25

angularjs-markdown-editor

Fully working Markdown Editor written in AngularJS
JavaScript
41
star
26

datatify

Simple single class used to display network status change notification (switch between WIFI, 3G and No connection)
Objective-C
37
star
27

snarkyed

GPU rendered text editor written in Rust
Rust
36
star
28

comby-search

A code search tool based on Comby
Rust
36
star
29

gitq

JavaScript
36
star
30

txtask

Ask Ollama about your local text files
Rust
34
star
31

adb.py

Tiny Python lib to write your own debug script for Android application with ADB
Python
32
star
32

xaudio

TypeScript
32
star
33

snackymini-keyboard

Snackymini Keyboard
C++
29
star
34

markto

Awesome notepad replacement with Markdown support for your Mac
JavaScript
26
star
35

nodben

Benchmark tool for any running process for Mac - Written in NodeJS
JavaScript
25
star
36

tab-list-arc-browser

Tab List extension for Arc Browser
JavaScript
25
star
37

speech

A tool to practice English speaking
Vue
24
star
38

coffee-now

☕ CoffeeScript Playground
CoffeeScript
24
star
39

golang-checklist

A checklist to learn Golang
24
star
40

vscode-nord-light

23
star
41

slack-save-plugin

Save any Slack messages
JavaScript
23
star
42

helix-ui

Rust
22
star
43

actix-taskqueue

Rust
21
star
44

vim-espresso-tutti

Vim Script
21
star
45

productivity-watcher

Swift
19
star
46

mini-searcher

A dead simple search engine for static site blogs
Rust
19
star
47

vscode-tokyo-city

18
star
48

huy.rocks

My personal site
TypeScript
18
star
49

xaudio-cli

TUI Youtube Player using Elm Architecture and mpv JSON IPC
Rust
18
star
50

org-journal-list

A package to display a list of org-notes with preview.
Emacs Lisp
17
star
51

arduino-flappybird

Flappy Bird on Arduino
C++
17
star
52

vscode-github-light-monochrome

16
star
53

electron-typescript-react-tailwind-parcel

A template for making desktop app with cool technologies
JavaScript
16
star
54

opencl-benchmark

Sample program to compare calculation performance between CPU and GPU
C
16
star
55

lit

🔥 lit is an experimental WebSocket game server based on Engine.IO
JavaScript
16
star
56

vimouse-rs

Use keyboard to control your mouse
Rust
16
star
57

highl.it

Highlighter anywhere
JavaScript
15
star
58

csn-search

Search for music album on old.chiasenhac.vn
Haskell
15
star
59

trello-rs

Trello on your terminal
Rust
14
star
60

jsondb-rs

A RESTful JSON storage service
Rust
14
star
61

object-model

🐙 object-model is a tiny package that help you use any object as a Model.
JavaScript
14
star
62

js-chip8-emulator

Chip 8 Emulator - Experimental
JavaScript
14
star
63

rcat

Colorized cat written in Rust
Rust
14
star
64

pure-js-vote

🍔 Yet another hamburger...
HTML
13
star
65

vscode-forest-all-nighter

13
star
66

skimGPT

Too lazy to read the full article? Skim it
Rust
12
star
67

dungeon-generator

TypeScript
12
star
68

clinews

News reader for hackers, geek, and command-line fanatics =]]
Python
12
star
69

roboplex-font

11
star
70

stocktable

Quick and extendable stock comparision tool
TypeScript
11
star
71

scrollreading

An extension to help you read better
JavaScript
11
star
72

makefile-boilerplate

🐤 A boilerplate for any-language-projects using Makefile.
Makefile
11
star
73

tradingview-mac-rs

Unofficial TradingView Desktop App
Rust
11
star
74

manga-frame-detect-opencv

Detect frames in a Manga page with OpenCV
Jupyter Notebook
10
star
75

highlightjs-focus

Line focus plugin for Highlight.js
TypeScript
10
star
76

web-debugger

TypeScript
10
star
77

firefox-safari

My attempt to make Firefox as compact as Safari
CSS
10
star
78

snacky-news-rs

Rust
9
star
79

gust-lang

It's not Go, it's not Rust, it's Gust
Rust
9
star
80

use

Things I use
9
star
81

crogue

A WIP roguelike game
C
9
star
82

lemontree-dark-vscode

9
star
83

slack-message-deleter

Delete Slack message from any channel using Slack's Web API
JavaScript
9
star
84

bubble-sort-visualized

Visualized Bubble Sort Algorithm
C
9
star
85

react-stackoverflow-flair

🎨 your own StackOverflow flair
JavaScript
8
star
86

nextjs-tailwind-typescript

JavaScript
8
star
87

idea-cli

Command-line based tool for task management
JavaScript
8
star
88

json-grep

Rust
8
star
89

kip

Kipalog CLI tool
Ruby
7
star
90

vim-nord-light-brighter

Vim Script
7
star
91

source-reading

A collection of source code reading notes
7
star
92

lit-demo

Demo game made with lit
JavaScript
6
star
93

typescript-react-template

JavaScript
6
star
94

bookmarks

HTML
6
star
95

Sizzular

Sizzle (jQuery Selector) + AngularJS Starter Code for any website
HTML
6
star
96

emacs-config

Emacs Lisp
6
star
97

chrome-json-formatter

JSON Formatter for Google Chrome
JavaScript
6
star
98

dotfiles

My dotfiles, feel free to use, feel no to blame
Shell
6
star
99

poloniex-cli

Poloniex Command Line
JavaScript
6
star
100

sergaem

WebSocket Multiplayer Game Server in Rust
Rust
6
star