views:

174

answers:

3

Hello all

Im trying to write an ascii game for an assignment. The program must be written entirely in c, no c++. How can i get the program to open a window capable of rendering ascii art? I want to create a window of a certain size, that is capable of printing in multiple colors. A simple console window is insufficient.

Also, on a related note, can anyone show me a function that will write directly to the buffer? printf is too slow, and doesnt seem to be versatile enough for the graphics i want to produce.

Any help will be greatly appreciated. Thanks in advance.

+3  A: 

A simple console window is insufficient.

I disagree. A console window is perfectly fine for anything you seem to want to do. Colours, full ascii range, highlighting...

Also, on a related note, can anyone show me a function that will write directly to the buffer? printf is too slow,

How fast do you need to write? If you're forming the strings yourself and calling printf, it essentially just copies it into the buffer for you.

Anon.
My game is a sonic style game, where you run from left to right and speed is key. while doing some simple tests with printfs, i found that printing strings to the screen was slow enough that i could see the screen flicker.
Flopdong
Make sure to set stdout to use output buffering. It does this on it's own, but by default it will flush the buffer after every `\n`
Earlz
The screen flicker is caused by drawing lines sequentially - you want to disable auto-flushing of the buffer and manually flush it after every screen.
Anon.
A: 

try ncurses

altho i dont think it works for windows at this time (v5.7)

or even AAlib

ShoeLace
there is a ncurses port somewhere that actually works for windows.. I've used it before.
Earlz
A: 

You want the Windows Console API there are functions in there to do exactly what you are asking. For example use SetConsoleDisplayMode to change the console size.

shf301