Browse Source

fixed the score print

master
VissaMoutafis 5 years ago
parent
commit
56d5b96e98
  1. 2
      src/Controller.cpp
  2. 8
      src/Graphics.cpp

2
src/Controller.cpp

@ -29,7 +29,7 @@ Controller::~Controller(){delete snake;}
static void printScore(unsigned int _score){ static void printScore(unsigned int _score){
string str = "Score: " + to_string(_score); string str = "Score: " + to_string(_score);
printMsg(0, 0, (char*)str.c_str()); //-1, -1 because otherwise it'll be printed inside the game box
printMsg(-1, -1, (char*)str.c_str()); //-1, -1 because otherwise it'll be printed inside the game box
} }
int Controller::act(void){ int Controller::act(void){

8
src/Graphics.cpp

@ -62,7 +62,13 @@ void printChar(int y, int x, graphics_input img){
} }
void printMsg(int y, int x, char* str){ void printMsg(int y, int x, char* str){
mvwaddstr(_box, y, x, str);
if(y>0 && x>0)
mvwaddstr(_box, y, x, str);
else{
if(y < 0) y = 2 + y;
if(x < 0) x = 0;
mvaddstr(y, x, str);
}
refresh(); refresh();
wrefresh(_box); wrefresh(_box);
} }

Loading…
Cancel
Save