是否有任何控制台和QUOT;图形"库对于.NET?控制台、有任何、图形、QUOT

2023-09-02 02:08:13 作者:久醉绕心弦

我在这里的基本目标是写Kroz王国的.NET重拍。对于那些不熟悉游戏:

My basic goal here is writing a .NET remake of Kingdom of Kroz. For those not familiar with the game:

http://www.indiefaqs.com/index.php/Kingdom_of_Kroz

http://www.youtube.com/watch?v=cHwlNAFXpIw

本来就应该是一个快速的分心项目给我所有的通用企业WCF / WF / LINQ2SQL /等工作项目占用了我大部分时间最近休息。虽然我努力的结果是可玩的,它看起来是因为我重绘一切都在每帧的方式一样绝对的屁股(即使是基于控制台的游戏)。

Originally it was supposed to be a quick distraction project to give me a break from all the generic enterprise WCF/WF/LINQ2SQL/etc work projects occupying most of my time lately. While the result of my effort is playable, it looks like absolute arse (even for a console-based game) because of the way I'm redrawing everything in each frame.

我所知道的一些替代方法,但在短暂的测试中,我已经做了,他们仍然不提供显著的性能或美学的好处。我不想再打一个图书馆,'模拟'一个控制台,如果我能帮助它。我想preFER与引擎盖下的正确的Win32控制台API的工作,而不是使用它直接,如果我能帮助它。请记住,这是一个明显的小众使用的情况下,这将是普遍接受这个最好的方法?是否有什么特别的最佳控制台绘图技术之一应该知道的?我不介意游泳的PInvoke的海洋,只要它仍然结束了一个快速,反应灵敏,高效的控制台UI编组。

I'm aware of some alternate approaches but in the brief tests I've done they still don't offer significant performance or aesthetic benefits. I don't want to resort to a library which 'emulates' a console if I can help it. I'd prefer to work with the proper Win32 console API under the hood, but not to work with it directly if I can help it. Keeping in mind that it's a distinctly niche use case, what would be the 'generally' accepted best approach for this? Are there any particularly optimal console 'drawing' techniques one should be aware of? I don't mind swimming in a sea of PInvoke and marshalling as long as it still ends up with a fast, responsive and efficient console UI.

推荐答案

http://msdn.microsoft.com/en-us/library/ms682073(v=VS.85).aspx

若干/很多这样的功能,你可能需要使用的P / Invoke的,但他们应该做你所需要的。你可以写在缓冲区任意位置,并获得基于密钥的,非缓冲输入。通常你开始GetStdHandle()来获取句柄到控制台输入和输出的流,然后你调用从上面的列表中选择相应的功能之一做一些事情,比如WriteConsoleOutputCharacter(),或PeekConsoleInput()。

Some/many of these functions you might need to use P/Invoke for, but they should do what you need. You can write at arbitrary locations in the buffer and get key-based, non-buffered input. Usually you start with GetStdHandle() to get handles to the console input and output "streams" and then you call one of the appropriate functions from the above list to do something, like WriteConsoleOutputCharacter(), or PeekConsoleInput().

我曾经写了一个库,创建一个使用Windows控制台和滑动Win32和C.有趣的项目,一个进程窗口系统,但我不知道它是现在。

I once wrote a library to create an in-process windowing system using the Windows console and plain Win32 on C. Fun project, but I don't know where it is now.