0

I am coding a RPG python game battle system, my objective is that every time I take damage, my HP reduces and its updates as soon as I take damage without re-printing the HP bar. Can the HP bar, which is already printed on the top of the console, update simultaneously or replace the old HP bar at the same position (top of the console) instead of printing a separate updated HP bar at the bottom?

Here's the screenshot of the code (the actual is too long and it involves a classes from other modules and etc.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
Cavio
  • 23
  • 4
  • 1
    This needs some additional library like "curses" or a more simple library to control the terminal. – Michael Butscher Feb 26 '22 at 21:29
  • 1
    Also requires a terminal/console that supports curses (i.e. ANSI escape sequences). – martineau Feb 26 '22 at 22:02
  • What about [this](https://stackoverflow.com/questions/5419389/how-to-overwrite-the-previous-print-to-stdout-in-python)? Search for related topics like this. There are many details discussed in this field. – Shayan Feb 26 '22 at 22:26

0 Answers0