Skip to content

Jerenaux/ensemble

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

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 required or exported.

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.