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?

2
  • 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. Commented Jan 16, 2022 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. Commented Jan 16, 2022 at 19:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.