Welcome! |
|
|
|
|
Site Forum |
|
|
|
|
|
Topic: GDI+ Flickering Problem
|

|
| GDI+ Flickering Problem |
| << Prev Topic | Next Topic >> |
| mouse88 |
| Posted: July 22 2009 at 1:58pm | IP Logged
|
|
|
Newbie

Group: Newbie
Joined: July 22 2009 Location: United Kingdom Posts: 1
|
I am having problems with flickering when drawing squares
to a picture box. Heres my main form code:
Code:
Public Class FrmGame
Public ArrayBlocks(15, 30) As Block
Public BlockSize As New Size(15, 15)
Private Sub FrmGame_Load(ByVal sender As Object,
ByVal e As System.EventArgs) Handles Me.Load
'Reduce Flicker'
SetStyle(ControlStyles.DoubleBuffer, True)
SetStyle(ControlStyles.AllPaintingInWmPaint,
True)
End Sub
Private Sub FrmGame_Paint(ByVal sender As Object,
ByVal e As System.Windows.Forms.PaintEventArgs) Handles
Me.Paint
'Draw Game Board To Picture Box'
Dim GameBoard As New GameBoard
GameBoard.Draw(ImgMain.Handle)
'Draw First Line Of Blocks To Picture Box'
Dim X As Integer
Dim Color1 As Color = Color.Blue
Dim Color2 As Color = Color.LightBlue
Dim InitialLoc As New Point(0, 0)
For X = 0 To 14
ArrayBlocks(X, 0) = New Block(BlockSize,
InitialLoc, Color1, Color2)
ArrayBlocks(X, 0).Draw(ImgMain.Handle)
'Update Initial Location'
InitialLoc.X += 15
'Change Block Colors'
If Color1 = Color.Blue And Color2 =
Color.LightBlue Then
Color1 = Color.Red
Color2 = Color.Yellow
Else
Color1 = Color.Blue
Color2 = Color.LightBlue
End If
Next X
Me.Invalidate()
End Sub
End Class
The Rectangle which is my game board is drawn as per
normal no flickering, however when the 15 blocks/squares
are drawn they are all flickering for some reason. I may
be doing something wrong as until now i've been creating
basic games with picture boxes. If anyone has any advice
i would appreciate it greatly.
|
Online Status: Offline
|
|
| |
| creek23 |
| Posted: August 22 2009 at 12:52pm | IP Logged
|
|
|
KonsolScript Master

Group: Senior Member
Joined: December 23 2005 Location: Philippines Posts: 173
|
Make sure that the form AutoRedraws.
__________________ Visit my scriptable 2D game engine at http://www.konsolscript.org
|
Online Status: Offline
|
|
| |
| blupig |
| Posted: January 02 2010 at 1:49pm | IP Logged
|
|
|
Newbie

Group: Newbie
Joined: January 02 2010 Posts: 3
|
Use a backbuffer.
|
Online Status: Offline
|
|
| |
| 1 User(s) are browsing this topic, 1 Guest(s) and 0 Member(s) |
| 0 Members: |
|
|
|
|
|
If you wish to post a reply to this topic you must first login If you are not already registered you must first register
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You can vote in polls in this forum
|
|