...
 
Commits (5)
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -5,7 +5,7 @@
MicroTD - Tower Defense Game for Arduboy
version: 1.3
version: 1.4
Miloslav "drummyfish" Ciz, 2018, license: CC0 (public domain)
......@@ -127,6 +127,9 @@
#define UPGRADE_DAMAGE_FRACTION_INCREASE 2 /**< Fractional increase (+ 1/x) of
damage by upgrade. */
#define BUTTON_REPEAT_DELAY 20 ///< Initial button repeat delay, in frames.
#define BUTTON_REPEAT_PERIOD 6 ///< Button repeat period in frames.
#define CHEAT_NONE 0
#define CHEAT_MONEY 1
......@@ -2659,20 +2662,40 @@ void drawMap()
}
}
uint8_t buttonRepeatCounter = BUTTON_REPEAT_DELAY;
inline void checkButton(uint8_t button, bool checkRepeat=false)
{
if (arduboy.justPressed(button))
{
game.buttonDown(button);
}
if (checkRepeat)
{
if (arduboy.pressed(button))
{
if (buttonRepeatCounter == 0)
{
if (arduboy.frameCount % BUTTON_REPEAT_PERIOD == 0)
game.buttonDown(button);
}
else
buttonRepeatCounter--;
}
else if (arduboy.justReleased(button))
buttonRepeatCounter = BUTTON_REPEAT_DELAY;
}
}
void handleInputs()
{
#define checkButton(b)\
if (arduboy.justPressed(b))\
game.buttonDown(b);
checkButton(A_BUTTON);
checkButton(B_BUTTON);
checkButton(LEFT_BUTTON);
checkButton(RIGHT_BUTTON);
checkButton(UP_BUTTON);
checkButton(DOWN_BUTTON);
#undef checkButton
checkButton(LEFT_BUTTON,true);
checkButton(RIGHT_BUTTON,true);
checkButton(UP_BUTTON,true);
checkButton(DOWN_BUTTON,true);
// cheat
......@@ -2721,8 +2744,8 @@ void loop()
handleInputs();
uint8_t updates =
game.mState == STATE_PLAYING_WAVE && arduboy.pressed(UP_BUTTON) ?
GAME_SPEEDUP : 1;
game.mState == STATE_PLAYING_WAVE && arduboy.pressed(A_BUTTON) &&
arduboy.pressed(B_BUTTON)? GAME_SPEEDUP : 1;
for (uint8_t i = 0; i < updates; ++i)
game.update();
......