https://github.com/jerenaux/ensemble
An experimental collectively designed multiplayer online game
https://github.com/jerenaux/ensemble
crow-design multiplayer-browser-game multiplayer-online-game nodejs phaser socket-io
Last synced: 12 months ago
JSON representation
An experimental collectively designed multiplayer online game
- Host: GitHub
- URL: https://github.com/jerenaux/ensemble
- Owner: Jerenaux
- License: mit
- Created: 2017-04-10T14:04:36.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-10T14:32:25.000Z (about 9 years ago)
- Last Synced: 2025-06-03T00:35:02.895Z (about 1 year ago)
- Topics: crow-design, multiplayer-browser-game, multiplayer-online-game, nodejs, phaser, socket-io
- Language: JavaScript
- Homepage: http://www.dynetisgames.com/2017/04/20/project-ensemble/
- Size: 691 KB
- Stars: 15
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Project Ensemble
Project Ensemble is an experiment in *crowd design*, where players, developers and artists collaborate to collectively design a browser-based multiplayer online game.
For a detailed description of the project, visit [the website](http://www.dynetisgames.com/2017/04/20/project-ensemble/).
## Tour of the code
`server.js` is the starting point of the Node app and is located at the root of the repository. It includes all the necessary modules
and handles the interactions with the app.
### Game-related code
All files related to the game itself are located in the `game` directory. `assets` contains the images, sounds, JSON files, etc. used in the game. `js` containts the source code, split into `client`-related code, `server`-related code and `shared` code, which is used by both the client and the server.
For the client, `game.js` is where the main logic is located. This file often references the `Client` object, which is defined in `client.js` and acts as the interface between the game and the server (if you contribute, please put all interactions involving Socket.io in `client.js`). For the server, the main logic is located in `gameserver.js`.
As the codebase grows, the code should be split into "classes" as much as possible, located in their own js files in the `game` folder. `Player.js` is one such example.
##### About shared code
Having the same code used by both the server and the client allows to avoid code duplication. One example is the `MovementManager`, which allows to check for collisions using the exact same code on the server and the client. Since the management of dependencies is different in the browser and in Node.js, a variable `onServer` is created in each common file, to check if the file is being loaded on the server or on the client. It can then be used to decide if some modules should be `require`d or `export`ed.
Within one shared class, there can be methods that will only be used (or *can* only be used) either on the client and the server. Others will have a slightly different behaviour depending on the environment (client or server). The same `onServer` variable is used each time to detect what is the situation, and act accordingly (have a look at the `BlocksManager.addBlock()` method for one such example).
### App-related code
"App" refers to the web page, the voting interface, the forms to suggest features and submit art, etc. The app-relate code is
located in the `app` directory. As the app was made with AngularJS,
the code is mostly distributed in terms of `views` (the HTML templates of what should be displayed, including `index.html`) and `controllers` (the logic that
controls the behavior of the views). This organization is controlled in `app.js`
## Running the code
You need to have Node.js and MongoDB installed, and MongoDB running. Clone the repository and type in a terminal where you cloned it: `npm install` and then `node server.js`. Then navigate to `localhost:8081`.
If you get an error involving `compile: [(...args) => this._convertDataImages(...args)],`, your Node.js is probably not up to date (check with `node -v`). Update it to the most recent version and it should work.