NCurses program not working right?

Alright, so I'm beginning to make my roguelike, TintRL, where you kill vamps. So, in making a test for the game loop working before I start coding any features, I think I'm using getch() wrong. I want it to quit when I press q, but it just functions as a normal getch.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <ncurses.h>


bool gameon = true;

char menchar = getch();

int main()
{
  initscr();
  noecho();
  while (gameon = true)
  {
    printw("bob");
    getch();
    if (menchar = 'q')
    {
      endwin();
    }
  }  
}
closed account (o3hC5Di1)
Hi there,

You only seem to be assigning getch(); to menchar whilst you need it to change every time a new character is pressed in the loop.

Also, try using getchar(), it seems to be the c++ variant of getch():
http://www.cplusplus.com/reference/clibrary/cstdio/getchar/

If that doesn't help, please be a little bit more specific about what the program does / doesn't do.

All the best,
NwN
Topic archived. No new replies allowed.