I am doing an exercise from The C++ Programming language (page 325, exercise 12.7, question 2).
I开发者_开发问答t says:
Implement a simple graphics system using whatever graphics facilities are available on your system (if you dont have a good graphics system or have no experience with one, you might consider a simple "Huge bit ASCII implementation" where a point is a character position and you write by placing a suitable container, such as * in a position)
Now, what I gather from that, is that if I dont want to use GDI+ or Direct X then I can do this in a console app using chars like _
,*
, or -
.
Am I thinking about this the right way?
If I am, am I right in thinking that I need to be able to draw a character anywhere on the console?
If so, how do I draw a char
anywhere on the console?
Or I could be wrong and you can tell he what I might want to try (not GDI+ / DirectX if possible)
In order to draw a character anywhere to the console you really need to use an operating system specific library for console access, or a cross-platform console library.
If you were doing this for Windows you would use the Windows Console API (MSDN), a function that could draw a character to a specific location is FillConsoleOutputCharacter (MSDN).
It used to be that ANSI escape sequences could be used, but having read your question and investigated here, it seems these no longer exist.
The best option appears to be to use the windows console APIs, documented here.
There looks to be a pretty good example of how you might proceed here.
Good luck with this, it sounds interesting!
Fond memories of doing this in computer class, back when we had chaarcter sets with ▄ ▀ █. Double-resolution graphics ;). If you wanted one in column 8, you'd print 7 spaces in front of it. And if you wanted it at line 3, you'd print two \n
in front. But yes, you'd have to consider up front what you were going to draw. To redraw one character, you'd have to redraw everything.
精彩评论