0

I am making a game using curses on python. My code is:

from curses import wrapper
import curses

def main(stdscr):
    score = 0

    stdscr.erase()
    text = '''
╔╗─╔╦═══╦╗──╔╗──╔═══╗╔╗
║║─║║╔══╣║──║║──║╔═╗║║║
║╚═╝║╚══╣║──║║──║║─║║║║
║╔═╗║╔══╣║─╔╣║─╔╣║─║║╚╝
║║─║║╚══╣╚═╝║╚═╝║╚═╝║╔╗
╚╝─╚╩═══╩═══╩═══╩═══╝╚╝

    '''
    stdscr.addstr(10, 10,text, curses.A_BOLD)
    score += 1
    stdscr.refresh()
    stdscr.getkey()

wrapper(main)

The y co-ordinate seem to be working fine. However the x co-ordinate always defaults to 0 and text is pushed to the left of the screen. Is this a bug or am I missing something?

eyah
  • 111
  • 1
  • 8
  • Your first line in the string is just a newline character `\n`, so you aren't seeing that x=10 is applied. Having any other char at the start of the string will confirm this. I tried to `strip()` the string, it partially works but only the first line starts at x=10. I assume you want the entire text to be indented? I am not familiar with this module to give a full answer, but hopefully this helps in your search. – shriakhilc Jan 16 '22 at 19:20
  • 1
    The only thing that the X coordinate affects is the position of the newline that ends the first line of `text` - which isn't visible anyway. Each newline moves the insertion point to the left edge of the next line, the initial X coordinate no longer matters. I think the easiest solution would be to create a curses subwindow, with left/top margins wherever you want them, and insert the text into that. – jasonharper Jan 16 '22 at 19:23

0 Answers0