Problem when rendering my game.

cnc4

New member
Joined
Apr 18, 2015
Messages
2
Programming Experience
Beginner
Hello I am making a simple snake game with images using that:

Code:
  private void rendering()        {


            while (true)
            {
            
                if (pbCanvas.InvokeRequired)
                {
                    //pbCanvas.Refresh();
                    pbCanvas.Invoke(new MethodInvoker(delegate { Refresh(); })); //delete the images that where on the canvas(picture box).
                    render(); //render the snake and the food.
                    //tryed without threading but it's the same.
                }
                
            }
               
            
            }
And at start:
Code:
Thread th = new Thread(render);
            th.Start();
But the snake always flusing, i mean that he does show up but then he just disappear and show up agian. Dont know how to explain it properly (Same the food). :(
 
Last edited:

xReaperGFX

New member
Joined
Apr 10, 2015
Messages
3
Programming Experience
3-5
Hello I am making a simple snake game with images using that:

Code:
  private void rendering()        {


            while (true)
            {
            
                if (pbCanvas.InvokeRequired)
                {
                    //pbCanvas.Refresh();
                    pbCanvas.Invoke(new MethodInvoker(delegate { Refresh(); })); //delete the images that where on the canvas(picture box).
                    render(); //render the snake and the food.
                    //tryed without threading but it's the same.
                }
                
            }
               
            
            }
And at start:
Code:
Thread th = new Thread(render);
            th.Start();
But the snake always flusing, i mean that he does show up but then he just disappear and show up agian. Dont know how to explain it properly (Same the food). :(

Make the form DoubleBuffered it should fix your flickering issue

Code:
this.DoubleBuffered = true;
 

cnc4

New member
Joined
Apr 18, 2015
Messages
2
Programming Experience
Beginner
Amm thx! i will try this as soon as i can...
 
Top Bottom