emath.js v8.2.1
NOTE: THIS PACKAGE IS IN DEVELOPMENT AND IS SUBJECT TO MAJOR CHANGES
Abstract
This project started when I was trying to create my first incremental game. I found it difficult to implement certain systems like upgrades and saving. When I eventually made those systems, I wanted to make a package so I could streamline those tools. After a few months of development, I have finally developed it into a presentable state (I should have started it with v0.1.0 instead of v1.0.0 . . .).
Example Usage
import { E } from "emath.js";
import { Game } from "emath.js/game";
// For CDN usage:
// const { E, Game } = eMath;
// Initialize game
const coinGame = new Game();
// Create a new currency
const coins = coinGame.addCurrency("coins");
// Create upgrades
coins.static.addUpgrade({
id: "upg1Coins", // Unique ID
cost: level => level.mul(10), // Cost of 10 times the level
maxLevel: E(1000),
effect: (level) => {
coins.static.boost.setBoost({
id: "boostUpg1Coins",
effect: n => n.plus(level.mul(11)).sub(1),
});
},
});
// Initialize / Load game
coinGame.init();
coinGame.dataManager.loadData();
// Gain coins
coins.static.gain();
// Buy (max) upgrades
coins.static.buyUpgrade("upg1Coins");
// Hotkeys
coinGame.keyManager.addKey([
{
id: "gainCoins",
name: "Gain Coins",
key: "g",
onDownContinuous: () => coins.static.gain(),
},
{
id: "buyUpgrades",
name: "Buy Upgrades",
key: "b",
onDownContinuous: () => coins.static.buyUpgrade("upg1Coins"),
},
]);
// Saving and Loading
window.addEventListener("beforeunload", () => {
coinGame.dataManager.saveData();
});
coinGame.eventManager.setEvent("autoSave", "interval", 30000, () => {
coinGame.dataManager.saveData();
console.log("Auto Saved!");
});
Installation
Install via npm (recommended)
npm install emath.js
Include using CDN
Note: There is no development build for CDN, as it is used for nodejs.
emath.js
<script src="https://cdn.jsdelivr.net/gh/xShadowBlade/emath.js/dist/main/eMath.min.js"></script>
emath.js/game
<script src="https://cdn.jsdelivr.net/gh/xShadowBlade/emath.js/dist/game/eMath.game.min.js"></script>
emath.js/pixiGame
CDN usage for this module is not yet available.
Check out the documentation!
2 days ago
7 days ago
11 days ago
15 days ago
16 days ago
19 days ago
27 days ago
2 months ago
2 months ago
3 months ago
3 months ago
6 months ago
7 months ago
6 months ago
6 months ago
5 months ago
6 months ago
6 months ago
6 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago