diff --git a/main.cpp b/main.cpp index 02a5b08..eb0d8c8 100644 --- a/main.cpp +++ b/main.cpp @@ -6,8 +6,6 @@ #include #include #include -#include -#include using namespace std; #define termMaxX 145 @@ -22,10 +20,10 @@ using namespace std; void drawVoid(){ - printf("\033[1;32m\033[40m \033[0m"); //\033[1;32m green text,\033[40m black bg, display " ",\033[0m set default + printf("\033[1;32m\033[40m \033[0m"); } void drawSnake(){ - printf("\033[1;32m\033[40m*\033[0m"); //\033[1;32m green text,\033[40m black bg, display *,\033[0m set default + printf("\033[1;32m\033[40m*\033[0m"); } void SetCursorPosition(int XPos, int YPos) { printf("\033[%d;%dH",YPos+1,XPos+1); @@ -120,8 +118,6 @@ int crashBomb(int posX, int posY, int bombX[100],int bombY[100], bool bombShown[ } void gameOver(int score){ - //clear(); - //initscr(); cbreak(); noecho(); scrollok(stdscr, TRUE); @@ -136,6 +132,7 @@ void gameOver(int score){ printf("\033[45m \033[0m"); //\033[41m } } + //Draws GAME OVER SetCursorPosition((paMaxX/2)-34,(paMaxY/2)-7); printf("\033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m "); SetCursorPosition((paMaxX/2)-34,(paMaxY/2)-6); @@ -151,7 +148,7 @@ void gameOver(int score){ SetCursorPosition((paMaxX/2)-34,(paMaxY/2)-1); printf("\033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m \033[41m \033[45m "); printf("\e[?25h"); - + //For score values with multiple digits int scoreShift=0,temp=score; while(temp>=10){ @@ -162,9 +159,7 @@ void gameOver(int score){ printf("Score: %d", score); SetCursorPosition((paMaxX/2)-19,(paMaxY/2)+6); printf("Enter you name: "); - SetCursorPosition((paMaxX/2)-1,(paMaxY/2)+6); - //cin>>score; - + //Save player scores at $HOME/.config/cursedSnakeGameScores FILE *cmd=popen("echo -n $HOME", "r"); char result[100]={0x0}; fgets(result, sizeof(result), cmd); @@ -179,7 +174,7 @@ void gameOver(int score){ return; } string playerName; - + //Asks for player name scanf("%s",playerName.c_str()); fprintf(fptr,"%s %d\n", playerName.c_str(), score); fclose(fptr); @@ -188,7 +183,6 @@ void gameOver(int score){ int mainMenu() { int currentButtonState=0,menuStarted=0; printf("\e[?25l");//ปิดcursor - //initscr(); cbreak(); noecho(); scrollok(stdscr, TRUE); @@ -301,7 +295,7 @@ int mainMenu() { void showScores() { endwin(); int line=0,currentLine=0; - char c; + char c; //UserInputCharacter FILE *cmd=popen("echo -n $HOME", "r"); char result[100]={0x0}; fgets(result, sizeof(result), cmd); @@ -375,9 +369,7 @@ void showScores() { currentLine++; } } - fclose(fptr); - drawFrame(); SetCursorPosition(5,3); printf("Name"); @@ -390,18 +382,13 @@ void showScores() { noecho(); scrollok(stdscr, TRUE); nodelay(stdscr, TRUE); - //int j=0; - while(1){ usleep(10000); c = getch(); if(showLinesIndicator==1){ - if(c==upArrow){ for(int i=1;i=bombAmount){ bombLoop++; bombShown[bombLoop-2]=1; bombAmount=bombLoop*3; - } for(int i=0;i<100;i++){ if(bombShown[i]==1){ - SetCursorPosition(bombX[i],bombY[i]); printf("\033[1;97m\033[41m \033[0m"); } - } - // } return snakeLength-2; } - - -/*int mainmenu(){ - for(int i=0;i