From 56d5b96e98c1d95c0c266fd2af25aa057e684998 Mon Sep 17 00:00:00 2001 From: VissaMoutafis Date: Mon, 24 Feb 2020 12:52:31 +0200 Subject: [PATCH] fixed the score print --- src/Controller.cpp | 2 +- src/Graphics.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Controller.cpp b/src/Controller.cpp index 733c1c2..61aaf87 100755 --- a/src/Controller.cpp +++ b/src/Controller.cpp @@ -29,7 +29,7 @@ Controller::~Controller(){delete snake;} static void printScore(unsigned int _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){ diff --git a/src/Graphics.cpp b/src/Graphics.cpp index cab15a0..6ce0713 100755 --- a/src/Graphics.cpp +++ b/src/Graphics.cpp @@ -62,7 +62,13 @@ void printChar(int y, int x, graphics_input img){ } 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(); wrefresh(_box); }