Code Monkey home page Code Monkey logo

colyseus-tic-tac-toe's Introduction

Tic-Tac-Toe Multiplayer

Turn-based demonstration project using Colyseus.

This repository has:

  • server/: The Colyseus server, with tic-tac-toe room implementation.
  • javascript-pixi/: A JavaScript/PixiJS client-side project.
  • defold/: A Defold client-side project.

Running the server locally

You'll need two terminal windows open to be able to run this. One for the client, and one for the server:

Running the server

cd server
npm install
npm start

Important files to have look at

JavaScript / PixiJS

The JavaScript/PixiJS example uses:

Running the JavaScript/PixiJS client

cd javascript-pixi
npm install
npm start

Important files to have look at

Defold Engine

The Defold project was made by Selim Anaç.

License

MIT

colyseus-tic-tac-toe's People

Contributors

endel avatar sh-dave avatar spedwards avatar vapurrmaid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colyseus-tic-tac-toe's Issues

Module not found: Error: Can't resolve 'ws'

Did the following:

git clone https://github.com/endel/tic-tac-toe
cd tic-tac-toe
cd frontend
npm install
npm start

I get this error:

ERROR in ./node_modules/@gamestdio/websocket/lib/index.js
Module not found: Error: Can't resolve 'ws' in '/Users/johncantrell97/Development/opensource/tic-tac-toe/frontend/node_modules/@gamestdio/websocket/lib'
@ ./node_modules/@gamestdio/websocket/lib/index.js 1:837-850
@ ./node_modules/colyseus.js/lib/Connection.js
@ ./node_modules/colyseus.js/lib/Client.js
@ ./node_modules/colyseus.js/lib/index.js
@ ./src/Application.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/main.js
ℹ 「wdm」: Failed to compile.

Using node v11.10.0 (also tried with v8.11.4).
Using webpack 4.29.5

Any ideas? I feel like it has to be related to my node/webpack setup but I'm not sure what to try exactly. I also tried downgrading webpack and webpack-cli to the min version specified in package.json without any luck (same error).

npm install not working

Can someone confirm if npm install if working for them? This is what I'm getting:

npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: 🙌  Thanks for using Babel: we recommend using babel-preset-env now: please read https://babeljs.io/env to update!
npm WARN deprecated [email protected]: Package no longer supported. Contact [email protected] for more info.
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated

> [email protected] postinstall /mnt/c/PauloCoding/From github/colyseus-tic-tac-toe/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> [email protected] postinstall /mnt/c/PauloCoding/From github/colyseus-tic-tac-toe/node_modules/ejs
> node ./postinstall.js

Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)


> [email protected] postinstall /mnt/c/PauloCoding/From github/colyseus-tic-tac-toe/node_modules/yeoman-environment/node_modules/ejs
> node --harmony ./postinstall.js

Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)


> [email protected] install /mnt/c/PauloCoding/From github/colyseus-tic-tac-toe
> npm install --prefix ./server && npm install --prefix ./frontend && npm run build --prefix ./frontend

npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated

> [email protected] postinstall /mnt/c/PauloCoding/From github/colyseus-tic-tac-toe/server/node_modules/nodemon
> node bin/postinstall || exit 0

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN [email protected] No repository field.

added 356 packages from 292 contributors and audited 357 packages in 19.652s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

npm WARN saveError ENOENT: no such file or directory, open '/mnt/c/PauloCoding/From github/colyseus-tic-tac-toe/frontend/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/mnt/c/PauloCoding/From github/colyseus-tic-tac-toe/frontend/package.json'
npm WARN frontend No description
npm WARN frontend No repository field.
npm WARN frontend No README data
npm WARN frontend No license field.

up to date in 0.23s
found 0 vulnerabilities

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /mnt/c/PauloCoding/From github/colyseus-tic-tac-toe/frontend/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/mnt/c/PauloCoding/From github/colyseus-tic-tac-toe/frontend/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/paulocoelho/.npm/_logs/2020-07-26T22_12_25_606Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 254
npm ERR! [email protected] install: `npm install --prefix ./server && npm install --prefix ./frontend && npm run build --prefix ./frontend`
npm ERR! Exit status 254
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/paulocoelho/.npm/_logs/2020-07-26T22_12_25_660Z-debug.log

I've also noticed that the folder javascript-pixi might have been called frontend at some point, since the install script refers to a folder that doesn't exist. But even by fixing that the error is still there. I'll keep investigating.

Run time error doing `npm start` in frontend

I did npm install then npm start and get the following error log

vindexus:frontend$ npm install
npm WARN [email protected] No repository field.

up to date in 4.925s
vindexus:frontend user$ npm start

> [email protected] start /Users/vindexus/personal/tic-tac-toe/frontend
> webpack-dev-server

/Users/vindexus/personal/tic-tac-toe/frontend/node_modules/webpack-cli/bin/config-yargs.js:89
        describe: optionsSchema.definitions.output.properties.path.description,
                                                  ^

TypeError: Cannot read property 'properties' of undefined
    at module.exports (/Users/vindexus/personal/tic-tac-toe/frontend/node_modules/webpack-cli/bin/config-yargs.js:89:47)
    at Object.<anonymous> (/Users/vindexus/personal/tic-tac-toe/frontend/node_modules/webpack-dev-server/bin/webpack-dev-server.js:84:40)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/vindexus/.npm/_logs/2018-09-25T23_34_00_922Z-debug.log$```

Unable to deploy server on Heroku

Hi, I am trying to connect the game that is on my local machine to the colyseus server which is hosted on Heroku.
But I am not able to connect with it.

here are the logs on heroku.

2021-10-23T07:41:15.039589+00:00 app[web.1]: npm ERR! 
2021-10-23T07:41:15.039657+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2021-10-23T07:41:15.039728+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-10-23T07:41:15.045286+00:00 app[web.1]: 
2021-10-23T07:41:15.045384+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-10-23T07:41:15.045432+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-10-23T07_41_15_041Z-debug.log
2021-10-23T07:41:15.173245+00:00 heroku[web.1]: Process exited with status 1
2021-10-23T07:41:15.256693+00:00 heroku[web.1]: State changed from starting to crashed
2021-10-23T07:42:38.416822+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=colyseus-test-freak.herokuapp.com request_id=7d661d8d-6eaf-45a8-892b-8aeb755ea1f7 fwd="160.202.38.236" dyno= connect= service= status=503 bytes= protocol=https
2021-10-23T07:42:44.066803+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=colyseus-test-freak.herokuapp.com request_id=77789ddd-9643-4ed8-ba4c-afe58ccd7dee fwd="160.202.38.236" dyno= connect= service= status=503 bytes= protocol=https
2021-10-23T07:43:39.796204+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=OPTIONS path="/:3553/matchmake/joinOrCreate/tictactoe" host=colyseus-test-freak.herokuapp.com request_id=a9fa2344-59f9-490a-b3c2-d07183e83cad fwd="160.202.38.236" dyno= connect= service= status=503 bytes= protocol=https
2021-10-23T07:43:43.421986+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=OPTIONS path="/:3553/matchmake/joinOrCreate/tictactoe" host=colyseus-test-freak.herokuapp.com request_id=431efe2a-f442-4d2f-99a4-6ebd21808618 fwd="160.202.38.236" dyno= connect= service= status=503 bytes= protocol=https
2021-10-23T07:43:46.920820+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=colyseus-test-freak.herokuapp.com request_id=bdc6d6e0-9d0b-4b31-ac59-1b15584f3461 fwd="160.202.38.236" dyno= connect= service= status=503 bytes= protocol=https
2021-10-23T07:43:47.423678+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=colyseus-test-freak.herokuapp.com request_id=e7d649d3-0071-420c-b623-441250a0866d fwd="160.202.38.236" dyno= connect= service= status=503 bytes= protocol=https
2021-10-23T07:44:03.797299+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=OPTIONS path="/:3553/matchmake/joinOrCreate/tictactoe" host=colyseus-test-freak.herokuapp.com request_id=ec174790-425d-4f10-86c5-fa5588b13173 fwd="160.202.38.236" dyno= connect= service= status=503 bytes= protocol=https

Please suggest the way forward.

I have updated the URL in game from

const endpoint = (window.location.hostname.indexOf("herokuapp") === -1)
  ? "ws://localhost:3553" // development (local)
  : `${window.location.protocol.replace("http", "ws")}//${window.location.hostname}` // production (remote)

to

const endpoint = (window.location.hostname.indexOf("herokuapp") === -1)
  ? "https://colyseus-test-freak.herokuapp.com/:3553" // development (local)
  : `${window.location.protocol.replace("http", "ws")}//${window.location.hostname}` // production (remote)

Question: single dimension array for board?

Hi,

this sample code has been quite helpful. I am curious of the reason for using a single dimension array vs a 2d array for the board.

Better performance? Simplified (or required for serialization? personal preference?

Can't deploy to Heroku

I can see from the repo home page that there's a version of this deployed to, and hosted upon Heroku at:
http://tictactoe-colyseus.herokuapp.com/

But, when I try to deploy a tictactoe fork to Heroku, the build fails.

I guess this app last deployed to Heroku 3 months ago. Is there a chance that something has changed in Heroku?

-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 10.x...
       Downloading and installing node 10.15.0...
       Using default npm version: 6.4.1
       
-----> Building dependencies
       Installing node modules (package.json)
       
       > [email protected] install /tmp/build_440857dca46023323bda307c0179e1ac
       > npm install --prefix ./server && npm install --prefix ./frontend && npm run build --prefix ./frontend
       
       
       > [email protected] postinstall /tmp/build_440857dca46023323bda307c0179e1ac/server/node_modules/colyseus
       > npm run -s donate
       
       Love Colyseus? Support its development by becoming a backer:
        > https://www.patreon.com/endel
       added 309 packages from 290 contributors and audited 4632 packages in 6.935s
       found 0 vulnerabilities
       
       
       > [email protected] postinstall /tmp/build_440857dca46023323bda307c0179e1ac/frontend/node_modules/colyseus.js
       > npm run -s donate
       
       Love Colyseus? Support its development by becoming a backer:
        > https://www.patreon.com/endel
       added 22 packages from 22 contributors and audited 9291 packages in 4.71s
       found 0 vulnerabilities
       
       
       > [email protected] build /tmp/build_440857dca46023323bda307c0179e1ac/frontend
       > webpack
       
       /tmp/build_440857dca46023323bda307c0179e1ac/node_modules/webpack-cli/bin/config-yargs.js:89
       				describe: optionsSchema.definitions.output.properties.path.description,
       				                                           ^
       
       TypeError: Cannot read property 'properties' of undefined
           at module.exports (/tmp/build_440857dca46023323bda307c0179e1ac/node_modules/webpack-cli/bin/config-yargs.js:89:48)
           at /tmp/build_440857dca46023323bda307c0179e1ac/node_modules/webpack-cli/bin/webpack.js:60:27
           at Object.<anonymous> (/tmp/build_440857dca46023323bda307c0179e1ac/node_modules/webpack-cli/bin/webpack.js:515:3)
           at Module._compile (internal/modules/cjs/loader.js:689:30)
           at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
           at Module.load (internal/modules/cjs/loader.js:599:32)
           at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
           at Function.Module._load (internal/modules/cjs/loader.js:530:3)
           at Module.require (internal/modules/cjs/loader.js:637:17)
           at require (internal/modules/cjs/helpers.js:22:18)
       npm ERR! code ELIFECYCLE
       npm ERR! errno 1
       npm ERR! [email protected] build: `webpack`
       npm ERR! Exit status 1
       npm ERR! 
       npm ERR! Failed at the [email protected] build script.
       npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.fEY81/_logs/2019-01-18T13_39_44_035Z-debug.log
       npm ERR! code ELIFECYCLE
       npm ERR! errno 1
       npm ERR! [email protected] install: `npm install --prefix ./server && npm install --prefix ./frontend && npm run build --prefix ./frontend`
       npm ERR! Exit status 1
       npm ERR! 
       npm ERR! Failed at the [email protected] install script.
       npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.fEY81/_logs/2019-01-18T13_39_44_099Z-debug.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       Some possible problems:
       
       - Node version not specified in package.json
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

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.