Sign in to follow this  

Flickering and the windows console

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

A while ago, I made a memory game program which uses ascii graphics to represent the cards. Everything works fine but I notice that there tends to be a bit of flickering whenever the user finished picking the cards and the program redraws everything again. How do you eliminate this? Oh I am programming in C and using the Dev c++ IDE and the windows console api.

Share this post


Link to post
Share on other sites
I don't believe that there is a way to solve it except to utilize an actual graphics library which allows for double buffering and text output (or you could alternatively write your own text functions or get a text library)

SDL, OpenGL, DirectX all allow frame buffers.

Your flickering issue comes from the text being updated while the screen is refreshing and before the whole scene is ready to be shown. Double buffering can fix this by first setting up the pixels to draw and then flipping the screen only when ready to display.

It could also be (and this is a related problem) due to your clearscreen function simply pushing the text off the screen as opposed to actually clearing the screen properly.

My reccomondation would be SDL for an ascii game because of it's simplicity and input/sound functionality.

Share this post


Link to post
Share on other sites
For single buffer you should redraw only necessary pixels. When the card is moved, you fill the old rectangle with the background, everything outside that rectangle won't need redrawing. The flickering shouldn't appear anymore but it requires a little bit more work. You can archive this by masking.

A better alternative: Windows provides a number of function that support block reading and writing. You may simulate the effect of double buffering by having a second console screen buffer. When drawing, you provide that buffer pointer to WriteConsoleOutput () or WriteConsoleOutputCharacter ().

Better yet, GameTutorials has quite a few tutorials on 2D games using console and Win32 drawing routines, you may take a look at that site.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this