Had a quick scan through the code and like you have a nice consistent style :)
Small games like this teach you a lot.
Not sure why this stood out but thought I would point out. You had this piece of code
if (firstPlay)
{
StartGame();
firstPlay = false;
widthBox.Enabled = false;
heightBox.Enabled = false;
}
else
if (!firstPlay)
{
ResetGame(width, height);
StartGame();
}
The second 'if' is not required the else means it will always be !firstPlay if the first 'if' fails
if (firstPlay)
{
StartGame();
firstPlay = false;
widthBox.Enabled = false;
heightBox.Enabled = false;
}
else
{
ResetGame(width, height);
StartGame();
}
:)
Thank you! I know it is not required, but anyway, it's checked very quickly because we talk about one byte. If it was a function .. that would have been the worst case .. because of a complexity probably larger than O (1) ;)
I guess for me it is more maintenance later on. I am in a code base at work that has been growing 10 years+ and not adding the extra if means there is less chance someone will come in for a bug fix and miss updating if the main if changes etc.
The less code the better in my books, I do all I can to minimise code size. :)