CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2015
    Posts
    2

    Problem when rendering my game.

    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(rendering);
                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).

  2. #2
    Join Date
    Apr 2012
    Posts
    43

    Re: Problem when rendering my game.

    I'm assuming your canvas is some kind of control or a Form. You need to set the DoubleBuffered property on this control/Form to True to prevent flicker. Also, don't delete the previous frame when rendering a new one. Simply draw the new frame over the old one.

  3. #3
    Join Date
    Apr 2015
    Posts
    2

    Re: Problem when rendering my game.

    Quote Originally Posted by Niya View Post
    I'm assuming your canvas is some kind of control or a Form. You need to set the DoubleBuffered property on this control/Form to True to prevent flicker. Also, don't delete the previous frame when rendering a new one. Simply draw the new frame over the old one.

    well i solved my problem long time ago using the canvas paint event while using the event's graphic. thx anyway.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured