I am currently working on an incremental game, Gold Rush, and am trying to create a total gold earned value that stores all of the gold the user has earned throughout the game, including the gold spent. So far I have put it so every time the player earns gold by clicking or incrementors it adds to the value. As the game gets more complex I find that this becomes harder to do, and I am trying to make a function that adds 1 to the totalGold variable every time it adds one to the gold variable. So far I have tried this:
if (gameData.gold + 1) {
gameData.totalGold + 1;
}
The incrementor profits are gathered like this
function goldPerSecond() {
return gameData.pickaxeGold + gameData.dwarfGold + gameData.gooseGold + gameData.mineGold + gameData.dragonGold + gameData.stoneGold + gameData.stationGold + gameData.leprechaunGold + gameData.sheepGold + gameData.rayGold + gameData.mergerGold;
}
And the clikcing profits gathered like this
function collectGold() {
gameData.gold += gameData.clickinGold
gameData.clicks += 1
gameData.totalGold += gameData.clickinGold
}
I am fairly new to JavaScript and do not know any other way I could do it. It would be preferable if I did not have to use JQuery. Thank you.