diff --git a/main.cpp b/main.cpp index eb0d8c8..e5bc10f 100644 --- a/main.cpp +++ b/main.cpp @@ -157,6 +157,8 @@ void gameOver(int score){ } SetCursorPosition(((paMaxX/2)-5)-(scoreShift/2),(paMaxY/2)+3); printf("Score: %d", score); + SetCursorPosition(2,paMaxY-2); + printf("Input your name (without spaces!) and press ENTER to return to main menu."); SetCursorPosition((paMaxX/2)-19,(paMaxY/2)+6); printf("Enter you name: "); //Save player scores at $HOME/.config/cursedSnakeGameScores @@ -176,7 +178,7 @@ void gameOver(int score){ string playerName; //Asks for player name scanf("%s",playerName.c_str()); - fprintf(fptr,"%s %d\n", playerName.c_str(), score); + fprintf(fptr,"%d %s\n",score , playerName.c_str()); fclose(fptr); } @@ -208,6 +210,16 @@ int mainMenu() { printf("\033[45m \033[107m#####\033[45m \033[107m#####\033[45m \033[107m#\033[45m \033[107m#\033[45m \033[107m#####\033[45m \033[107m#######\033[45m \033[107m######\033[45m \033[107m#####\033[45m \033[107m#\033[45m \033[107m#\033[45m \033[107m#\033[45m \033[107m#\033[45m \033[107m#\033[45m \033[107m#\033[45m \033[107m########"); SetCursorPosition((paMaxX/2)-44,(paMaxY/2)-5); printf("\033[45m GAME\033[0m"); + //Author info + SetCursorPosition(paMaxX-8,paMaxY-3); + printf("\033[45mMade by\033[0m"); + SetCursorPosition(paMaxX-39,paMaxY-2); + printf("\033[45mPongpeera Wongprasitthiporn (64010543)\033[0m"); + //Instructions + SetCursorPosition(2,paMaxY-3); + printf("\033[45mUse ARROW KEYS to navigate\033[0m"); + SetCursorPosition(2,paMaxY-2); + printf("\033[45mENTER to select\033[0m"); if(menuStarted<=3){ for(int i=0;i $HOME/.config/cursedSnakeGameScores.tmp && mv $HOME/.config/cursedSnakeGameScores.tmp $HOME/.config/cursedSnakeGameScores"); int line=0,currentLine=0; char c; //UserInputCharacter FILE *cmd=popen("echo -n $HOME", "r"); @@ -346,7 +359,6 @@ void showScores() { playerName[i]=""; scores[i]=""; } - //*fptr = *fopen(fullpath.c_str(),"r"); if(fptr == NULL) { perror("Error in opening file"); return; @@ -354,13 +366,10 @@ void showScores() { bool scoreName=0; while(currentLine!=line){ c=fgetc(fptr); - - if(scoreName==0){ - + if(scoreName==1){ playerName[currentLine]+=c; } - if(scoreName==1){ - + if(scoreName==0){ scores[currentLine]+=c; } if(c==' ') scoreName=1; @@ -371,10 +380,12 @@ void showScores() { } fclose(fptr); drawFrame(); - SetCursorPosition(5,3); - printf("Name"); SetCursorPosition(50,3); + printf("Name"); + SetCursorPosition(15,3); printf("Score"); + SetCursorPosition(5,3); + printf("Rank"); currentLine=0; bool showLinesIndicator=1; if(line<=20) showLinesIndicator=0; @@ -405,25 +416,30 @@ void showScores() { if(currentLine+20!=line) currentLine++; } for(int i=currentLine;i<20+currentLine;i++){ - - SetCursorPosition(5,4+i-currentLine); - printf("%s", playerName[i].c_str()); SetCursorPosition(50,4+i-currentLine); + printf("%s", playerName[i].c_str()); + SetCursorPosition(15,4+i-currentLine); printf("%s", scores[i].c_str()); + SetCursorPosition(5,4+i-currentLine); + printf("%d", i+1); } SetCursorPosition(1,paMaxY-2); printf("lines %d-%d",currentLine+1,currentLine+21); } if(showLinesIndicator==0){ for(int i=currentLine;i