diff --git a/include/Graphics.h b/include/Graphics.h index a02d416..6cb27f9 100644 --- a/include/Graphics.h +++ b/include/Graphics.h @@ -21,4 +21,6 @@ void refreshScreen(void); void printChar(int y, int x, graphics_input img); void printMsg(int y, int x, char *str); char readChar(int y, int x); -int readInpt(); \ No newline at end of file +int readInpt(); + +void advanceDifficulty(void); \ No newline at end of file diff --git a/src/Controller.cpp b/src/Controller.cpp index 43dde6f..746d120 100644 --- a/src/Controller.cpp +++ b/src/Controller.cpp @@ -23,6 +23,7 @@ int Controller::act(void){ if (snake->hasBitSnack(this->snack.getY(), this->snack.getX()) == true) { + advanceDifficulty(); generateSnack(this->snack); this->snake->incSize(); } diff --git a/src/Graphics.cpp b/src/Graphics.cpp index 77f57e2..6c2ea8c 100644 --- a/src/Graphics.cpp +++ b/src/Graphics.cpp @@ -75,3 +75,7 @@ int readInpt(){ return getch(); } +void advanceDifficulty(void){ + if(sleepTime > 28000000) // we set 28000000 as teh min sleep time + sleepTime -= 1000000; +} \ No newline at end of file diff --git a/src/Snack.cpp b/src/Snack.cpp index 910ccd8..a4dad7f 100644 --- a/src/Snack.cpp +++ b/src/Snack.cpp @@ -10,8 +10,8 @@ void generateSnack(Point &snack){ int x, y; - x = (rand() + 1) % GAME_RIGHT_WALL_X; - y = (rand() + 1) % GAME_BOTTOM_WALL_Y; + x = rand() % GAME_RIGHT_WALL_X + 1; + y = rand() % GAME_BOTTOM_WALL_Y + 1; snack.setPoint(y, x);