# I don't have any ideas to program

This topic is 4140 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

##### Share on other sites
Now, that looks like a fun idea to work out. Thanks alot!

It appears, however, that the time has come to create a system for console drawing(the continuus stream of chararrays rolling down the console won't do this time).
I remember gametutorials had some stuff on this subject, but since they've gone all commercial and are asking money for the tuts now, that's a no go. What I did find was this. Would anyone consider this a decent way to do console graphics?

Also, if anyone has some more ideas on games, please let me know.

##### Share on other sites
The complete details of Microsoft's Character-Mode Application interface can be found here. If you ask capn_midnight nicely, he might be able to unearth a link to the library they developed for his 4h console mode game contest.

##### Share on other sites
You could also take a look at the Windows Console tutorial by benryves, he provides a pretty good introduction to drawing in the console.

##### Share on other sites
I DO recommend using ben's tutorial. I also recommend this one. It is not as sexy as benryves', but it goes over important things. They both helped me a lot when I wanted to do character mode games. I DO NOT like the tutorial you posted. Mainly because it is dated, uses horrid programming style, uses a 2D array of CHAR_INFOs instead of the proper 1D array. I'm pretty sure you can do it entirely (and much more quickly) without using any arrays at all, because the windows console supports multiple buffers. It also uses a fairly stupid method for writing a string to certain coordinates when there are much, much better ways.

A quick note: If you want your game to be played fullscreen, then you must leave the dimensions at the defualt of 80x25 OR you can change it 80x50.

If you want to see an old absolutely horrible text based pong clone from my glory days of n00b-dom, here is the link. It was my first version of text pong before I ever learned anything about the Win32 console (except the gotoxy function which I knicked from another webpage). And I am quite embarrassed and ashamed by it. It compiled fine in Dev-C++, and it flickers like hell.

EDIT: Fixed the link. Oh and BTW, if you are an advanced n00b, consider libcaca.

EDIT2: Actually, forget pong. Look at what the mighty garyfletcher accomplished. Damn it. The link to the source code has been taken down. It was an awesome tetris clone. You can try asking him for the code.

[Edited by - skulldrudgery on October 18, 2006 2:51:27 AM]

##### Share on other sites
Ok, for anyone with interest in coding, try this one -

There is a simple land called Hedonia. The people of Hedionia speak the language Hedonian, which is as simple as its people. The Grammer of Hedonian goes this way

1. any letter from p-z is a sentence.
2. N followed by a sentence is a sentence.
3. C followed by two sentences is a sentence.

Can you write a program to validate a sentence in Hedonian?

##### Share on other sites
Quote:
 Original post by ammorphiusCan you write a program to validate a sentence in Hedonian?

Yuck. Sounds like Theory of Computation homework. :)

##### Share on other sites
Well you can make almost any game (well mostly turn based games) in console.

Go for poker, lights out, the tower of hanoi, checkers, Mastermind. Heck if you wana get complicated you would write a 2 player chess (the AI would be ridiculous to try at this point)

Just don’t let yourself be stuck on graphics. Sure when you think of a knight from chess you think of the horse head shaped piece but using the letter K works just as well from a game play standpoint.

##### Share on other sites
I thank you all for the replies.

Just a couple of responses from my side:

@Fruny and others: The guides that were mentioned aren't "direct hits". They give some curious errors and the ascii chart seems to be limited to '?', as opposed to the 'A' that the guide presents. But I guess I should look into it somewhat better. The read it through and ctrl-c ctrl-v method might not be the best. The 3h competition has been interesting to look into to, though. I'm convinced I'll find some usefull information there.

@Joystickgenie: I agree. I never had the intention to make great looking ASCII graphics. I'm just looking to make/get something to make simple character manipulation easy to implement in my games. Even for semi-static games like chess, being able to draw characters(the 8x8 grid with the K's and Q's P's etc on it) without having to draw one board under another is just so much cleaner. Again, I'm not going for pretty, I'm only going for functional(at least, for now).

##### Share on other sites
Quote:
 Original post by skulldrudgeryI DO recommend using ben's tutorial. I also recommend this one. It is not as sexy as benryves', but it goes over important things. They both helped me a lot when I wanted to do character mode games. I DO NOT like the tutorial you posted. Mainly because it is dated, uses horrid programming style, uses a 2D array of CHAR_INFOs instead of the proper 1D array. I'm pretty sure you can do it entirely (and much more quickly) without using any arrays at all, because the windows console supports multiple buffers. It also uses a fairly stupid method for writing a string to certain coordinates when there are much, much better ways.A quick note: If you want your game to be played fullscreen, then you must leave the dimensions at the defualt of 80x25 OR you can change it 80x50.If you want to see an old absolutely horrible text based pong clone from my glory days of n00b-dom, here is the link. It was my first version of text pong before I ever learned anything about the Win32 console (except the gotoxy function which I knicked from another webpage). And I am quite embarrassed and ashamed by it. It compiled fine in Dev-C++, and it flickers like hell.

I noticed you said you had problems with flickering using the console for your pong game, I had a similar problem when I created a memory game using the console. The way I overcame the problem was to create a CHAR_INFO array the same size as the screen and then draw everything to this before displaying it to the screen. It seems to work. Did you ever rectify the flickering in the console games you created and how did you do so? I would be interested in reading about any methods that people have used to overcome this.

You also mentioned something about windows console supporting multiple buffers -What do you mean by this and how would it be used in a game? Examples would be great.

##### Share on other sites
Yes, I was able to work around the flickering, the same way that you did: Writing to a CHAR_INFO buffer and then outputting the whole thing all at once. But I found that it is easier to just get Windows to create a second screen buffer. I use the second one to draw to and then copy it to the front buffer.

Windows automatically creates a screen buffer for the console. You can get a handle to that buffer using CreateFile().

HANDLE hConsoleFrontBuffer = CreateFile(    "CONOUT\$",    GENERIC_READ | GENERIC_WRITE,    FILE_SHARE_READ | FILE_SHARE_WRITE,    NULL,    OPEN_EXISTING,    0,    NULL );

Then create a second buffer.
HANDLE hConsoleBackBuffer = CreateConsoleScreenBuffer(    GENERIC_READ | GENERIC_WRITE,    FILE_SHARE_READ | FILE_SHARE_WRITE,    NULL,    CONSOLE_TEXTMODE_BUFFER,    NULL );

You do all your drawing to the backbuffer. It is convenient because you can use API functions to write to the buffer and you don't have to worry about bounds checking or memory management, for example if you wanted to resize the buffer at anytime, you could just use the appropriate API function.

Then you copy the backbuffer into the front buffer.
CHAR_INFO *tempbuffer = new CHAR_INFO[width * height];COORD size = {width, height};COORD pos = {0, 0};SMALL_RECT read = {pos.x, pos.y, size.x - 1, size.y - 1};SMALL_RECT write = read; ReadConsoleOutput(hConsoleBackBuffer, tempbuffer, size, pos, read);WriteConsoleOutput(hConsoleFrontBuffer, tempbuffer, size, pos, write); delete[] tempbuffer;

But you can also use multiple buffers in another way. You draw to an offscreen buffer, then instead of copying it to the front buffer, you use SetConsoleActiveScreenBuffer(), and the contents of the buffer will be immediately displayed. It is faster, but it causes the title bar of the console window to flicker.