This is the whole coding for the simon game. I am curious about how the code flow since each function do not return anything. And I am curious about this part:
Vincent19:
Does that means that we need to respond faster as the counter increases ?
///////////////////////////////////////////////////////////////////////////
// Slowly cranks up the pressure
void increaseSpeed()
{
if (turn == band)
{
beepdelay = 170;
pausedelay = 80;
return;
}
if (turn == band * 2)
{
beepdelay = 150;
pausedelay = 60;
return;
}
if (turn == band*3)
{
beepdelay = 120;
pausedelay = 40;
}
}
///////////////////////////////////////////////////////////////////////////
void loop()
{
for (int y = 0; y < WINSTATE; y++)
{
output();
input();
increaseSpeed(); // <---------------------------------- THIS is the part that makes it go faster as the game proceeds
} It calls the procedure "increaseSpeed" defined above
win();
}
in the "for" loop above, until the player either wins or loses, the output code is executed, then the input code is executed, then increasespeed, and then back to output, etc.
Ok, the speeed of the output goes faster. However, based on the full coding, does it means that the time I need to respond also getting faster ? Cause I seems to feel it when playing it ><
Ok, so either the player win or lose, it will follow the sequence : output > input > increase speed. And the final win(); is for what ?
Vincent19:
Ok, the speeed of the output goes faster. However, based on the full coding, does it means that the time I need to respond also getting faster ? Cause I seems to feel it when playing it ><
I don't think so, because RESPONSETIME is a defined constant and doesn't get changed.
Ok, so either the player win or lose, it will follow the sequence : output > input > increase speed. And the final win(); is for what ?
Up above is the definition of the win() "procedure". Looks like it beeps a certain way and flashes all the lights.
The loop() procedure at the bottom of the code is called over and over by the Arduino framework code. Therefore, win or lose, the player gets to keep going (but I think the score is reset once you lose). loop() - Arduino Reference
The loop() procedure "high-level" code being at the bottom is typical of c and c++ coding style, with the definitions of the procedures/functions/subroutines above.
Note I am answering these questions from quick, cursory examination of the code because it is well organized, factored, and very good names for the variables. (But I could have missed something )
Have you programmed in any other languages? If so, what?
It could be under 3s depending on the accuracy of your particular Arduino crystal or resonator. Why don't you devise a way to measure it against an atomic clock reference standard and get back to us with the results.
johncc:
It could be under 3s depending on the accuracy of your particular Arduino crystal or resonator. Why don't you devise a way to measure it against an atomic clock reference standard and get back to us with the results.
This is the video. You can observe that the timeout is quite fast sometimes..LOL