1

I need some help - I'm trying to create a roguelike using C++, and at the moment, I have a very simple little screen going, with a void() that generates a map, using "#" for walls and "." for floors. It can draw the player by comparing some integers which map the X and Y values of the player. I even have a little HUD which will display the player's stats.

But, the issue is, this is all being designed using a typical command-console window, and I'm starting to think I'm doing this wrong.

I want the player to move around this big empty room I have, by using the numpad -- this works. By using a Switch, I adjust the X and Y player value and then redraw the screen again.

Here's the issue. This actually redraws the screen all over again: it adds the 20-odd lines all over again, every single time I move. After a few moves, I have a command console window with text going for hundreds of lines.

So what am I doing wrong? Is there a command I don't know about to clear the screen?
Or am I doing this wrong from the start -- for instance, you have to press 'enter' to input your command, something that's not in any other roguelike. I'm a novice programmer, so any and all help is appreciated!

Thankyou!

Edit: Okay, thanks guys, I am now using PDCurses and trawling the docs to work out how to use the thing! Thanks again so much! Somebody please give the guy who suggested this a big tick! :D

Anonymous
  • 13
  • 2
  • I've merged your unregistered accounts. You can now leave comments under answers, edit your question or accept the answer that helped you the most. Please don't write replies as answers, those should be reserved strictly for answers that solve your problem. – Tim Post Aug 25 '11 at 08:55

3 Answers3

4

What method are you using to draw the screen, just normal iostream? For this kind of work a library called curses is normally recommended. It would let you draw text anywhere on the screen without scrolling or redrawing the entire screen.

john
  • 85,011
  • 4
  • 57
  • 81
0

I don't know of any reliable way to do it with portability, maybe try looking for some console oriented lib... Anyway under Windows you can still use system("cls");

Whiskas
  • 352
  • 1
  • 2
0

You can use the ansi escape sequence: printf ("\33[2]").

Nicolas Grebille
  • 1,332
  • 8
  • 15