是否有任何控制台“图形"?.Net 库? [英] Is there any console "graphics" library for .Net?

查看:28
本文介绍了是否有任何控制台“图形"?.Net 库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里的基本目标是编写 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/etc 工作项目中解脱出来.虽然我努力的结果是可玩的,但由于我在每一帧中重新绘制所有内容的方式,它看起来像绝对的屁股(即使是基于控制台的游戏).

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.

我知道一些替代方法,但在我所做的简短测试中,它们仍然没有提供显着的性能或美学优势.如果可以的话,我不想求助于模拟"控制台的库.我更愿意在幕后使用适当的 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. Fun 项目上创建一个进程内窗口系统,但我不知道它现在在哪里.

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.

这篇关于是否有任何控制台“图形"?.Net 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆