NerfStatTrak/StateReset.cpp
Mark van Renswoude 211740d51a Fixed #2 Persist counters
Added initialisation sketch and reset state
2016-12-10 12:01:43 +01:00

115 lines
1.6 KiB
C++

#include "StateReset.h"
#include "Globals.h"
#include "NerfStatTrakConfig.h"
#include "StateDefault.h"
void ResetState::setup()
{
intro = true;
introStart = currentTime;
outro = false;
selected = 0;
}
void ResetState::loop()
{
if (intro)
{
if (currentTime - introStart >= NerfResetIntroTime)
intro = false;
char text[] = "Reset";
display->writeTextLeft(text);
return;
}
if (outro)
{
loopOutro();
return;
}
if (buttonA->changed() && !buttonA->pressed())
{
switch (selected)
{
case 0:
setCurrentState(new DefaultState());
return;
case 1:
resetHits();
break;
case 2:
resetShots();
break;
case 3:
resetHits();
resetShots();
break;
}
outroStart = currentTime;
outro = true;
return;
}
if (buttonB->changed() && !buttonB->pressed())
{
selected++;
if (selected > 3)
selected = 0;
}
switch (selected)
{
case 0:
{
char text[] = "Cancel";
display->writeTextLeft(text);
break;
}
case 1:
{
char text[] = "Hits";
display->writeTextLeft(text);
break;
}
case 2:
{
char text[] = "Shots";
display->writeTextLeft(text);
break;
}
case 3:
{
char text[] = "Both";
display->writeTextLeft(text);
break;
}
}
}
void ResetState::loopOutro()
{
if (currentTime - outroStart >= NerfResetOutroTime)
{
setCurrentState(new DefaultState());
return;
}
char text[] = "Done";
display->writeTextLeft(text);
}