Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Game Development - Avoiding Flickers

I am developing a tetris like game in winforms(C# and .netframework 2.0). The winform has an background image and a picture-box which move down(new Location is assigned) at an interval of 500ms.

The problem is when picture-box moves down the background image of form flickers at the point where the picture-box was earlier located. If i don't use any background image, then there is no flickering.

Is there any graphics accelerator or any kind of solution using which the flickering problem can be solved.

like image 827
Ravi Jain Avatar asked Jan 17 '23 14:01

Ravi Jain


1 Answers

The term used for this is Double Buffering. The idea is simple - start with 2 panes but only display one. Draw to a hidden pane, and quickly swap the hidden and visible panes. Rinse and repeat for every transition (animation).

Luckily, you dont have to deal with the nuts and bolts of this in .NET, controls do it for you. This SO question will help you: How to double buffer .NET controls on a form?

like image 128
Jamiec Avatar answered Jan 20 '23 15:01

Jamiec