...
 
Commits (1)
......@@ -127,6 +127,9 @@
#define UPGRADE_DAMAGE_FRACTION_INCREASE 2 /**< Fractional increase (+ 1/x) of
damage by upgrade. */
#define CHEAT_NONE 0
#define CHEAT_MONEY 1
#define STATE_MENU 0 ///< In main menu.
#define STATE_PLAYING_MENU 1 ///< In game, game menu open.
#define STATE_PLAYING_BUILDING 2 ///< In game, building stage.
......@@ -1434,6 +1437,7 @@ struct Game
Spawner3 mSpawner3;
Spawner4 mSpawner4;
byte mCheat;
byte mMapNumber;
PlayGround mPlayground;
......@@ -1461,6 +1465,7 @@ struct Game
mFrame = 0;
mCreepCount = 0;
mSelectedMenuItem = 0;
mCheat = CHEAT_NONE;
mSound = false;
......@@ -1654,7 +1659,7 @@ struct Game
Tile *tile = mPlayground.getTile(mCursor);
byte cost = tile->mTower.getType().getUpgrageCost();
if (mMoney >= cost)
if (mMoney >= cost || mCheat == CHEAT_MONEY)
{
mPlayground.getTile(mCursor)->mTower.upgrade(
(mSelectedMenuItem == GAME_MENU_UPGRADE1) ? 0 : 1);
......@@ -1697,7 +1702,7 @@ struct Game
TowerType tt = towerTypes[mSelectedMenuItem];
if (tt.mPrice > mMoney)
if (tt.mPrice > mMoney && mCheat != CHEAT_MONEY)
return false; // not enough money
// build the tower
......@@ -1840,7 +1845,7 @@ struct Game
)
result.mState = ITEM_STATE_UNAVAILABLE; // no upgrade 2 for big towers
if (result.mPrice > mMoney)
if (result.mPrice > mMoney && mCheat != CHEAT_MONEY)
result.mState = ITEM_STATE_UNAVAILABLE;
byte pos = 0;
......@@ -2264,6 +2269,12 @@ void drawMenu()
arduboy.setTextBackground(WHITE);
arduboy.setCursor(2,55);
arduboy.print(item.mSubText);
if (game.mCheat != CHEAT_NONE && (game.mFrame / 4) % 2 == 0)
{
arduboy.setCursor(47,26);
arduboy.print(F("cheat!"));
}
}
void drawGameOver()
......@@ -2517,7 +2528,15 @@ void drawMap()
arduboy.setCursor(1,y);
arduboy.write('$');
arduboy.print(game.mMoney);
if (game.mCheat == CHEAT_MONEY)
{
arduboy.write('!');
arduboy.write('!');
arduboy.write('!');
}
else
arduboy.print(game.mMoney);
arduboy.setCursor(1 + 5 * 8,y);
arduboy.write('L');
......@@ -2654,9 +2673,14 @@ void handleInputs()
checkButton(DOWN_BUTTON);
#undef checkButton
// cheat
if (arduboy.pressed(UP_BUTTON) && arduboy.pressed(B_BUTTON))
game.mCheat = arduboy.pressed(DOWN_BUTTON) ? CHEAT_MONEY : CHEAT_NONE;
}
bool recordWritten; ///< Helper for detecting records and writing to EEPROM.
bool recordWritten = false; ///< For detecting records and writing to EEPROM.
void setup()
{
......@@ -2668,8 +2692,6 @@ void setup()
arduboy.clear();
arduboy.setFrameRate(FRAMERATE);
recordWritten = false;
if (EEPROM.read(EEPROM_START) != EEPROM_VALID_VALUE)
{
// EEPROM not valid => initialize it
......