A collection of games written in JavaScript or TypeScript.
- Clone the repository:
git clone https://github.com/ThomasFarineau/javascript-games.git
- Install the dependencies:
yarn install
- Start the development server:
yarn start
ornpm run start
- Fork the repository.
- Create a new branch (e.g.,
feature/name-of-the-feature
orgame/name-of-the-game
).
git checkout -b feature/name-of-the-feature
or
git checkout -b game/name-of-the-gamei
Make sure all executable files are executable by running:
chmod +x bin/*.js
npm link --force
To create a new game, run the following command:
jg create "Name of the game"
This will create a new folder src/games/nameOfTheGame
with the following structure:
nameOfTheGame (camelCase)
├── NameOfTheGame.ts (PascalCase)
├── NameOfTheGame.sass
├── instructions.md
├── config.json
├── assets
│ └── nav.svg
├── i18n
│ ├── fr.json
│ └── en.json
└── components
└── exampleComponent
├── ExampleComponent.ts
└── ExampleComponent.sass
NameOfTheGame.ts
: Exports a class that extends theGame
class.NameOfTheGame.sass
: Contains the styles for the game.instructions.md
: A markdown file displayed in the game's instructions modal and on the homepage.components
: An optional folder for any components used by the game.assets
: An optional folder for any assets used by the game, with a defaultnav.svg
icon, please keep svg format for icon.i18n
: Contains the translations for the game. Add a new file for each language you want to support. The file name should be the language code (e.g.,fr.json
for French). A game is available in the user's language if the translation is available. Otherwise, the game is displayed is not displayed in the list.config.json
: Contains game information such as title, description, author, tags, and ID.
Warning
It is strongly discouraged to change the ID in the config file.
To update the game list, run the following command:
jg reload
This updates/create the src/games/index.json
and src/games/index.ts
file with the list of games. It also refreshes the list in the navbar and on the homepage.
Caution
Do not push the index.json
file; it is included in .gitignore
for a reason.
When you are done with your feature, create a merge request to the main
branch of the repository.