def main(stdscr):
    #SETUP
    args = get_args()
    curses.curs_set(False)  #Turn off the cursor
    stdscr.clear()  #Clear the screen

    show_debug_text = args.debugging_output
    debugoutput.init(stdscr)

    gamewindow, panellist = layout_panels(stdscr)
    if args.mapfile:
        gameworld = GameWorld(genfunc=mapgenfuncs.load_from_file,
                              mapfile=args.mapfile)
    else:
        gameworld = GameWorld(genfunc=mapgenfuncs.empty_box,
                              width=20,
                              height=20)

    #GAME LOOP
    while True:
        try:
            draw_screen(stdscr,
                        gameworld,
                        gamewindow,
                        panellist,
                        show_debug_text=show_debug_text)
            keyinput.handle_key(stdscr.getkey())
            gameworld.update_world()
        except KeyboardInterrupt:
            #The user pressed Ctrl-C
            stdscr.refresh()
            sys.exit()
        except SystemExit:
            stdscr.refresh()
            sys.exit()