1

I am currently working on a text-adventure, which should have a more or less complex fight system. To create such, I decided to generate a 16x16 tile battlefield, which will be represented by ASCII-characters. But, because a fight may take more than turn, I don't want to reprint the battlefield multiple times, but delete the "old" one and print the new situation to the same place. But I suppose that it won't work with sys.stdout.write() and sys.stdout.flush() since there have to be removed multiple lines. So my question is: how do I accomplish my goal? At the moment I open a new console window, where everything is reprinted, which is ahem... not very elegant.

Another problem would be the cross-platform use of the programm.

TheWormKill
  • 23
  • 1
  • 6

1 Answers1

1

Check out the curses module (http://docs.python.org/2/library/curses.html).

thebjorn
  • 26,297
  • 11
  • 96
  • 138
  • Ah, I knew I forgot something: the solution is supposed to work on Windows and Unix, so curses won't work, I suppose. – TheWormKill Oct 13 '13 at 12:09
  • I believe there is a windows compatible curses module, although it isn't in the standard library. – rlms Oct 13 '13 at 12:10
  • I haven't tried this one myself, but here is a curses compiled for windows: http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses Otherwise you could use colorama on Windows (https://pypi.python.org/pypi/colorama). I've done a light wrapper that you may or may not find helpful: https://github.com/thebjorn/doscmd-screen – thebjorn Oct 13 '13 at 12:19
  • Thanks, I already found this link, I am currently trieing to get it to work. – TheWormKill Oct 13 '13 at 12:23
  • 1
    Did you ever get this to work? I'm doing a very similar thing. – David R. Feb 13 '15 at 01:04