W
wandoledzep
I have some very simple code that animates a square across the screen.
Why do the squares flicker so much during runtime?? I am asking because
I am working on a "breakout" type game and have about 20 squares on
screen that flicker like a SOB. What is all this about double buffering
I hear so much about? Any help would be awesome... (Let me remind you
that I _am_ a newbie so be gentle)
Peace,
LedZep
Dim g As Graphics
Dim rect As New Rectangle(20, 20, 100, 100)
Dim rect2 As New Rectangle(140, 20, 100, 100)
Dim rect3 As New Rectangle(260, 20, 100, 100)
Dim rect4 As New Rectangle(380, 20, 100, 100)
Dim x As Integer = 1
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
g = CreateGraphics()
g.FillRectangle(Brushes.BlueViolet, rect)
g.FillRectangle(Brushes.BlueViolet, rect2)
g.FillRectangle(Brushes.BlueViolet, rect3)
g.FillRectangle(Brushes.BlueViolet, rect4)
End Sub
Private Sub cmdTest_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdTest.Click
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
rect.X += x
Invalidate()
End Sub
End Class
Why do the squares flicker so much during runtime?? I am asking because
I am working on a "breakout" type game and have about 20 squares on
screen that flicker like a SOB. What is all this about double buffering
I hear so much about? Any help would be awesome... (Let me remind you
that I _am_ a newbie so be gentle)
Peace,
LedZep
Dim g As Graphics
Dim rect As New Rectangle(20, 20, 100, 100)
Dim rect2 As New Rectangle(140, 20, 100, 100)
Dim rect3 As New Rectangle(260, 20, 100, 100)
Dim rect4 As New Rectangle(380, 20, 100, 100)
Dim x As Integer = 1
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
g = CreateGraphics()
g.FillRectangle(Brushes.BlueViolet, rect)
g.FillRectangle(Brushes.BlueViolet, rect2)
g.FillRectangle(Brushes.BlueViolet, rect3)
g.FillRectangle(Brushes.BlueViolet, rect4)
End Sub
Private Sub cmdTest_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdTest.Click
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
rect.X += x
Invalidate()
End Sub
End Class