Pregunta

I am trying to develop a game(or any programs) in command line interface. I have the idea that how to develop an app in iOS or any other GUI platforms. I am really a basic c programmer. I only know printf to output the information. So actually I use printf("\n\n\n\n\n\n\n\n\n\n") to redraw the screen. It is definitely not the correct idea to develop with cli.

Just some simple questions:

  • Is there any way to control the command line interface? For example, refresh or redraw in each frame or change the scenes like what we do in GUI application.
  • How to enable keyboard control so that I can control my characters? Is there any way to control user input? I am really a beginner of c programming. All my command line programs use scanf and printf to interrupt with users.
  • Any books, websites, or libraries introduce this and I can start with?
¿Fue útil?

Solución

Look up ncurses.

It won't work on non-posix systems, but ncurses is a C library that will let you arbitrarily print characters anywhere on the screen. It's used a lot on linux to create user interfaces on the command line.

Source: http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/

Otros consejos

There is a famous console library that goes by the name of NCURSES but I'm not exactly sure it would be useful to you. By googling it I was able to discover that it is possible to build it on iOS.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top