-
Notifications
You must be signed in to change notification settings - Fork 18
Game Basics v7
- status: complete
- version: 7.x
- follows from: Create New Game
The game folder contains the following sub-folders and files:
Basics:
- game/
- public/
- waitroom/
Advanced:
- auth/
- channel/
- data/
- requirements/
- views/
- levels/
- package.json
In this basic guide we focus only on the items in bold, they are enough to get you started. For information about the other folders and files refers to the Game Advanced guide.
The files in the game
folder define the behavior of the game: the
default settings and available treatments, the sequence of game stages
and their implementation in different client types. The following
files and sub-folders are available:
- game.settings.js
- game.stages.js
- game.setup.js
- client_types/
Below we give a brief overview, but we will come back with more details at later.
The game.settings
file contains all the game variables. Examples of
game variables are: the timer for each step, the number of coins to win, or the exchange rate between experimental coins and some real world currency. Variables can be grouped together to create treatments. More details in the
settings and treatments page.
The game.stages
file defines the sequence of stages and steps
of the game. More details in the
game sequence page.
The game.setup
file is optional and it can be used to load
additional resources that are shared across all game rooms. For
example, a database of images' path should be imported here.
Technical note! The return value of this file is not sent to all connected clients, but it is available only to the logic client types (see next section). Moreover, it is "copied by reference," so that any modification will be shared across all game rooms too.
This folder contains the implementation of the sequence for different client types. Each client type goes through the same sequence, but can execute completely with different code.
You can have as many client types as you wish for, but at least two
are mandatory: the player
client type and the logic
client type.
The player
client type is what is going to be sent to the players
connecting with their browser to the game server.
The logic
client type is executed on the server and handles
operation like matching of players, computing the bonus, etc.
Each client type must be saved in its own file that determines also
the name of the client type, for example the player
client type is saved
in the player.js
file.
For more details, refer to the client types page.
The public/
folder contains all the static files that will be served
by the game; it must contain a file named index.htm
that will be served first to connecting clients.
Please note:
-
All files inside this directory are accessible through the browser. Do not store sensitive information in the
public/
folder. -
When running a game as default, sub-directories in
public/
may overshadow nodeGame's default directories. Default directories are:-
fonts/
,images/
,javascripts/
,lib/
,pages/
,sounds/
,stylesheets/
.
-
For instance, adding a lib/
folder inside public/
will overshadow the nodeGame's lib/
folder, from which libraries such as Bootstrap are served.
If you wish to create HTML pages dynamically, for example to customize the language of each page, you may use views, which are explained in the advanced guide.
The waitroom/
folder contains the waitroom and the waitroom
settings.
The waitingroom.settings.js
file controls the behavior of the
waiting room. The full list of options is described in the
Waiting Room page.
Go back to the wiki Home.
Copyright (C) 2021 Stefano Balietti
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.