unsigned long clickAmount;
unsigned long money;
unsigned long priceFirstUpgrade = 10;
unsigned long priceSecondUpgrade = 100;
unsigned long priceThirdUpgrade = 1000;
unsigned long priceFourthUpgrade = 10000;
unsigned long priceAutoUpgradeOne = 50000;
unsigned long priceAutoUpgradeTwo = 500000;
unsigned long priceCooldownUpgrade = 500;
unsigned long moneyPerClick = 1;
unsigned long autoMoney;
unsigned long totalMoney;
unsigned long cooldown = 500;
float priceModifier = 1.25;
float cooldownModifier = 0.8;
unsigned long resetModifier = 1;
unsigned long resetValue = 2500000;
void Initialize() {
// Initializes game and lets the player know what is happening
Serial.print("Cost of Upgrade 1 is: ");
Serial.print(priceFirstUpgrade);
Serial.println(", It gives +1 money per click.");
Serial.print("Cost of Upgrade 2 is: ");
Serial.print(priceSecondUpgrade);
Serial.println(", It gives +10 money per click.");
Serial.print("Cost of Upgrade 3 is: ");
Serial.print(priceThirdUpgrade);
Serial.println(", It gives +100 money per click.");
Serial.print("Cost of Upgrade 4 is: ");
Serial.print(priceFourthUpgrade);
Serial.println(", It gives +1000 money per click.");
Serial.print("Cost of Auto Upgrade 1 is: ");
Serial.print(priceAutoUpgradeOne);
Serial.println(", It autogenerates 1 money at very fast rates.");
Serial.print("Cost of Auto Upgrade 2 is: ");
Serial.print(priceAutoUpgradeTwo);
Serial.println(", It autogenerates 5 money at very fast rates.");
Serial.print("Cost of Cooldown Upgrade is: ");
Serial.print(priceCooldownUpgrade);
Serial.println(", It lowers your cooldown by 20%.");
Serial.println("The button that gives you money is yellow.");
Serial.println("The red button shows you your stats.");
Serial.println("The click upgrades are black buttons.");
Serial.println("The cooldown upgrade button is the blue button.");
Serial.println("The auto-generation upgrades are green buttons.");
Serial.println("The reset button is grey (it resets the game and adds a reset modifier).");
Serial.print("You can reset at ");
Serial.print(resetValue);
Serial.println(" money, this adds a modifier to your money, and the amount of money you need to reset gets bigger.");
Serial.println("Game begins");
delay(500);
Serial.println("NOW");
}
void setup() {
Serial.begin(9600);
pinMode(13, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
Initialize();
}
void loop() {
//money per click, click detection, and auto-money
if (digitalRead(13) == LOW) {
money += moneyPerClick*resetModifier;
totalMoney += moneyPerClick*resetModifier;
clickAmount++;
Serial.print("money: ");
Serial.println(money);
delay(cooldown);
}
money += autoMoney*resetModifier;
totalMoney += autoMoney*resetModifier;
// Upgrade 1
if (money >= priceFirstUpgrade && digitalRead(2) == LOW) {
moneyPerClick += 1;
money -= priceFirstUpgrade;
priceFirstUpgrade = priceModifier*priceFirstUpgrade;
Serial.print("Cost of Upgrade 1 is now: ");
Serial.println(priceFirstUpgrade);
delay(500);
} else if (digitalRead(2) == LOW && money < priceFirstUpgrade) {
Serial.println("not enough money");
delay(200);
}
// Upgrade 2
if (money >= priceSecondUpgrade && digitalRead(3) == LOW) {
moneyPerClick += 5;
money -= priceSecondUpgrade;
priceSecondUpgrade = priceModifier*priceSecondUpgrade;
Serial.print("Cost of Upgrade 2 is now: ");
Serial.println(priceSecondUpgrade);
delay(500);
} else if (digitalRead(3) == LOW && money < priceSecondUpgrade) {
Serial.println("not enough money");
delay(200);
}
// Upgrade 3
if (money >= priceThirdUpgrade && digitalRead(4) == LOW) {
moneyPerClick += 100;
money -= priceThirdUpgrade;
priceThirdUpgrade = priceModifier*priceThirdUpgrade;
Serial.print("Cost of Upgrade 3 is now: ");
Serial.println(priceThirdUpgrade);
delay(500);
} else if (digitalRead(4) == LOW && money < priceThirdUpgrade) {
Serial.println("not enough money");
delay(200);
}
// Upgrade 4
if (money >= priceFourthUpgrade && digitalRead(8) == LOW) {
moneyPerClick += 1000;
money -= priceFourthUpgrade;
priceFourthUpgrade = priceModifier*priceFourthUpgrade;
Serial.print("Cost of Upgrade 4 is now: ");
Serial.println(priceFourthUpgrade);
delay(500);
} else if (digitalRead(8) == LOW && money < priceFourthUpgrade) {
Serial.println("not enough money");
delay(200);
}
// Auto Upgrade 1
if (money >= priceAutoUpgradeOne && digitalRead(5) == LOW) {
autoMoney += 1;
money -= priceAutoUpgradeOne;
priceAutoUpgradeOne = priceModifier*priceAutoUpgradeOne;
Serial.print("Cost of Auto Upgrade 1 is now: ");
Serial.println(priceAutoUpgradeOne);
delay(500);
} else if (digitalRead(5) == LOW && money < priceAutoUpgradeOne) {
Serial.println("not enough money");
delay(200);
}
// Auto Upgrade 2
if (money >= priceAutoUpgradeTwo && digitalRead(6) == LOW) {
autoMoney += 5;
money -= priceAutoUpgradeTwo;
priceAutoUpgradeTwo = priceModifier*priceAutoUpgradeTwo;
Serial.print("Cost of Auto Upgrade 2 is now: ");
Serial.println(priceAutoUpgradeTwo);
delay(500);
} else if (digitalRead(6) == LOW && money < priceAutoUpgradeTwo) {
Serial.println("not enough money");
delay(200);
}
// Cooldown Upgrade
if (money >= priceCooldownUpgrade && digitalRead(9) == LOW) {
cooldown = cooldown*cooldownModifier;
money -= priceCooldownUpgrade;
priceCooldownUpgrade = priceModifier*priceCooldownUpgrade;
Serial.print("Cost of Cooldown Upgrade is now: ");
Serial.println(priceCooldownUpgrade);
} else if (digitalRead(9) == LOW && money < priceCooldownUpgrade) {
delay(500);
Serial.println("not enough money");
delay(200);
}
// Stats
if (digitalRead(7) == LOW) {
Serial.print("total money made: ");
Serial.println(totalMoney);
Serial.print("total clicks: ");
Serial.println(clickAmount);
Serial.print("speed of money autogeneration: ");
Serial.println(autoMoney);
Serial.print("money generated each click: ");
Serial.println(moneyPerClick);
Serial.print("cooldown time (in milliseconds): ");
Serial.println(cooldown);
delay(2000);
}
// Victory Condition, can be changed (if changed, remember to change that part in the initialize)
if (money >= resetValue && digitalRead(10) == LOW) {
resetValue = 1.9*resetValue;
resetModifier = 2*resetModifier;
Serial.println("YOU WIN!");
Serial.print("The reset value needed is now: ");
Serial.println(resetValue);
Serial.print("The reset modifier is now: ");
Serial.println(resetModifier);
Serial.println("Resetting in");
Serial.println("3");
delay(1000);
Serial.println("2");
delay(1000);
Serial.println("1");
delay(1000);
Serial.println("RESET");
delay(200);
money = 0;
moneyPerClick = 1;
autoMoney = 0;
}
}