Skip to content

Commit

Permalink
Add game docs
Browse files Browse the repository at this point in the history
  • Loading branch information
xShadowBlade authored Apr 26, 2024
1 parent 1b6dcd1 commit d75aa93
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
45 changes: 44 additions & 1 deletion documentation/docs/game/game-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,47 @@
id: game
title: Game
sidebar_label: Game
---
---

[Link to auto generated docs](https://xshadowblade.github.io/emath.js/typedoc/classes/game_Game.Game.html)

The game class is the main export of this library. It contains classes and methods for saving/loading, currencies, keybindings, and more.

## Uses

To make a `Game`, do the following:

```js title="game.js"
import { Game } from "emath.js/Game";

// Create a game with settings (optional)
const myGame = new Game({
name: {
title: "My Game", // Replace with the name of your game
id: "my-game", // ID of the game, for the name of the key in `localStorage`
},
settings: {
framerate: 30, // Affects the speed of tickers in `eventManager` and `keyManager`
},
});

export { myGame };
```

There are various managers/methods. Here are some examples:

```js title="gameExamples.js"
import { myGame } from "./game.js";

// See <GameCurrency>
const myCurrency = myGame.add

// See <EventManager>
myGame.eventManager.addEvent("IntervalEvent", "interval", 2000, () => {
console.log("Interval event that is executed every two seconds.");
});

// See <KeyManager>
```

For for information on constructor parameters, see the interface [`GameConfigOptions`](https://xshadowblade.github.io/emath.js/typedoc/interfaces/game_Game.GameConfigOptions.html).
2 changes: 1 addition & 1 deletion documentation/docs/game/game.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This category lists the primary exports of the package `emath.js/game`

## Table of Contents

- Game
- [Game](./game-class)
- GameAttribute (work in progress)
- GameCurrency (work in progress)
- ResetLayer (work in progress)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d75aa93

Please sign in to comment.