本文介绍了游戏在Linux终端:改变形象:在打印已经打印文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我只是执行pretty容易卡在游戏Linux终端。
我想实现的是改变图像的效果,基本上招印刷已经结束了打印的文本(我想我不能转载,除了具有\\ r同一行)。

Well, I'm simply implementing pretty easy card game in linux terminal.What I want to achieve is an effect of changing images, basically trick printing over already printed text(which I guess I cannot do except reprinting same line with \r).

我在想什么做的是让终端的高度,然后打印换行符直至终端的下缘,然后在终端将光标定位,这样就印在上面的最后一行。

What I was thinking to do is to get the terminal height, and then print newlines till the lower edge of the terminal, then position the cursor in terminal, so that the last line printed would be on top.

有没有什么好的方法可以做到这一点?我只是发现库调用。似乎可以做到这一点。它是一个很好的选择?

Are there any nice ways to do this? I've just found library called Ncurses. Seems it can do that. Is it a good option?

推荐答案

Ncurses的终端创建自己的字符窗口,并允许您存取权限,并在特定的位置覆盖字符。这看上去很适合你的游戏,在那里你可以在屏幕上任意位置画出人物艺术卡。方式比通过滚动()端子,模拟反正一样好。 - 中号Oehm

Ncurses creates its own character window in the terminal and allows you to acces and overwrite characters at specific positions. This looks perfect for your game, where you can draw character-art cards anywhere on the screen. Way better than emulating the same by scrolling () the terminal, anyway. – M Oehm

诅咒是最好的选择,因为兼容的库可用于所有操作系统(包括Windows命令行); ncurses的是Linux最好的之一。对于Linux和Unix终端,你也可以使用,通常被称为。例如,印刷\\ 033 [2; 3H将光标移动到第三列第二行,从上计数。反正我建议使用诅咒反正。 - 额定动物

Curses is the best option, as compatible libraries are available for all operating systems (including Windows command line); ncurses is the best one for Linux. For Linux and Unix terminals, you can also use ANSI escape codes, often called terminal codes. For example, printing "\033[2;3H" will move the cursor to the third column on the second row, counting from top. Anyway, I do recommend using Curses anyway. – Nominal Animal

这篇关于游戏在Linux终端:改变形象:在打印已经打印文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 04:21