Setting up the Game
After you have set up the basics, now it's time to set up the game.
- JavaScript
- TypeScript
script.js
const { Decimal, Game } = window.eMath;
// Initialize game with options
const gameOptions = {
// Name of the game (optional)
name: {
id: "coinGame", // ID of the game, used for saving and loading
name: "Coin Game", // Name of the game, cosmetic
version: "0.1.0", // Version of the game
},
};
const coinGame = new Game(gameOptions);
script.ts
import { Decimal } from "emath.js";
import { Game } from "emath.js/game";
// Initialize game with options
const gameOptions: GameConfigOptions = {
// Name of the game (optional)
name: {
id: "coinGame", // ID of the game, used for saving and loading
title: "Coin Game", // Name of the game, cosmetic
version: "0.1.0", // Version of the game
},
};
const coinGame = new Game(gameOptions);
Explanation:
- The
Game
class is imported from theeMath
object. This class is used to create the game. - The
gameOptions
object is defined to store the game's name, ID, and version. For all options, see the Game documentation.
After this step, you can continue to the currency tutorial.