I've been trying to fix this weird problem I get. The program starts up and it should print the map (it does) and wait, but it prints the map and then clears it and waits for input. I give it input (I just mash any button) and it does nothing with that input. After doing that it goes back to normal. And I also can't figure out why strings refuse to print.
Code:
#include <iostream>
#include <curses.h>
using namespace std;
//I'm cutting out stuff like constants declarations and prototypes
int main(void){
int ch;
string message;
initscr(); //Start curses
noecho(); //Don't talk back to me, boy
keypad(stdscr, true); //Turn on stuff like F1 and arrow keys
buildRoom(1, 1, 20, 10); //buildRoom(x, y, width, height);
buildRoom(13, 7, 10, 7);
buildRoom(23, 11, 6, 5);
buildRoom(30, 1, 6, 6);
room[10][10] = player; //Drop the player (an ampersand) at (10,10)
while(ch != 'q'){
printRoom();
cout<<message;
message = ""; //Reset the message given. [DOESN'T WORK]
ch = getch();
flushinp(); //Flush input stream to stop the sticky key problem
if(ch == KEY_UP || ch == KEY_LEFT || ch == KEY_DOWN || ch == KEY_RIGHT) movePlayer(ch);
else if(ch == 'v') message = "The floor appears to be made of dots."; //[DOESN'T WORK]
erase();
}
//On exit, reprint the map and print out a message, then wait for a keystroke
printRoom();
cout<<"Have a pleasant day! [Hit Any Key to Escape]";
ch = getch();
return 0;
}