Hello, sorry if this is a nooby question but I for the life of me cannot figure this out. I have a program I'm making which is essentially a lunar lander kind of program. I have a high score list I'm trying to work into the program. I have an array and a for loop that sorts everything fine. However, when I let the user enter their name for the high score list, the entire screen goes blue. My background disappears and I don't even see any prompts, but I can type, and whatever I do type will show up in the high score list after I hit enter. But nothing else shows besides the high score list. The background shows whenever I don't run the for loop to do the high score list, so I'm assuming the problem lies in there somewhere, but beyond that I'm stumped. Any help that you can provide, or even cleaning up the code, is greatly appreciated.
void highScore(int timer)
{
int playerScore = timer;
char playerName[10] = "TEMP";
//Placing where i want the high scores to print in the y-direction
int line = 300;
//Temporary placeholders
int temp, place, namePlace;
bool newHighScore = false, stop = false;
char stringTemp[10];
//Test values for my array so i can make sure sorting works
char names[10][10] = { "Test 1", "Test 2", "Test 3", "Test 4", "Test 5", "Test 6", "Test 7", "Test 8", "Test 9", "Test 10" };
int highScore[10] = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
//For loop to print the array values to the screen with an if statement inside to determine if a highscore
//was achieved or not.
for(int i = 0; i < 10; i++)
{
//if statement to determine if a new highscore was reached
if (playerScore < highScore[i])
{
//this sets place equal to the number in the array where the score is higher (0-9)
place = namePlace = i;
newHighScore = true;
stop = true;
dbCenterText(320, 240, "NEW HIGH SCORE!");
//A for loop to go through all the values that need moved (10-i) and bumps them all down one.
for(int counter = 10-i; counter >=0; counter--)
{
//HIGHSCORE NUMBER SORTING
//assigning the high score at the value where its being replaced to a temporary placeholder
temp = highScore[place];
//assigning the players sorce to the correct highScore array position
highScore[place] = playerScore;
//making score the temp value it was to repeat the cycle down the list
playerScore = temp;
//END OF HIGHSCORE NUMBER SORTING
//HIGHSCORE NAME SORTING
//assigning the string at the value replaced to a temporary placeholder
strcpy(stringTemp, names[place]);
//assigning the players name to the correct highScore array position
strcpy(names[place], playerName);
//making the playerName the temporary value so we can repeat the process.
strcpy(playerName, stringTemp);
//END OF HIGHSCORE NAME SORTING
//incrimenting place so that we proceed down the list (6 to 7 to 8 to 9, etc.)
place++;
}
}
//code to break out of the for loop so once the value is found it doesnt keep loking
if(stop == true)
{
break;
}
}
while (newHighScore == true)
{
dbPasteImage(winImage, 0, 0, 0);
dbText(0, 0, "You got a new high score!");
dbSetCursor(0, 15);
dbSync();
strcpy(names[namePlace], dbInput());
newHighScore = false;
}
for(int i = 0; i < 10; i++)
{
//printing the arrays to the screen
dbText(0, line, names[i]);
dbText(100, line, dbStr(highScore[i]));
line += 15;
}
//screen sync & pause for user
dbSync();
dbWaitKey();
}