Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any console "graphics" library for .Net? [closed]

Tags:

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

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.

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.

like image 324
nathanchere Avatar asked Oct 21 '10 05:10

nathanchere


2 Answers

You could try Curses-Sharp http://sourceforge.net/projects/curses-sharp/ or libtcod https://bitbucket.org/libtcod/libtcod

curses-sharp is a "A full featured, object-oriented, multi-platform C# wrapper for the curses terminal control library. "

and libtcod is "...a free, fast, portable and uncomplicated API for roguelike developpers providing an advanced true color console, input, and lots of other utilities frequently used in roguelikes."

like image 147
Vili Avatar answered Dec 11 '22 17:12

Vili


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

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().

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.

like image 26
siride Avatar answered Dec 11 '22 19:12

siride