Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I try to make a simple game, but when I create Graphics it flicker where bad. Even then I use a back buffer (double buffering). I draw to a Panel and not full screen.

 

First I create surface like this.

DDDevice = New Device(CreateFlags.Default)

DDDevice.SetCooperativeLevel(Panel, CooperativeLevelFlags.Normal)

 

CK.ColorSpaceHighValue = RGB(0, 0, 0)

CK.ColorSpaceLowValue = RGB(0, 0, 0)

 

SDesc.SurfaceCaps.PrimarySurface = True

FrontSurface = New Surface(SDesc, DDDevice)

 

SDesc.SurfaceCaps.PrimarySurface = False

SDesc.SurfaceCaps.OffScreenPlain = True

SDesc.SurfaceCaps.VideoMemory = True

SDesc.Height = Panel.Bottom - Panel.Top

SDesc.Width = Panel.Right - Panel.Left

 

BackSurface = New Surface(SDesc, DDDevice)

BackSurface.SetColorKey(ColorKeyFlags.SourceDraw, CK)

 

Clip = New Clipper(DDDevice)

Clip.Window = Panel

FrontSurface.Clipper = Clip

 

SDesc.Clear()

SDesc.SurfaceCaps.OffScreenPlain = True

SpriteSurface = New Surface("Sprite.bmp", SDesc, DDDevice)

SpriteSurface.SetColorKey(ColorKeyFlags.SourceDraw, CK)

 

SDesc.Clear()

SDesc.SurfaceCaps.OffScreenPlain = True

MapSurface = New Surface("BackGround.bmp", SDesc, DDDevice)

 

 

When I draw I do this.

 

 

Try

BackSurface.ColorFill(Color.Blue)

BackSurface.DrawFast(0, 0, MapSurface, Map.Rect, DrawFastFlags.DoNotWait)

BackSurface.DrawFast(0, 0, SpriteSurface, DrawFastFlags.SourceColorKey)

Catch ex As SurfaceLostException

InitializeSurface()

End Try

 

Dest = New Rectangle(PointToScreen(Panel.Location), Panel.ClientSize)

FrontSurface.Draw(Dest, BackSurface, DrawFlags.Wait)

 

 

Why does this program flicker so badly? :mad:

Posted

BackSurface.DrawFast(0, 0, MapSurface, Map.Rect, DrawFastFlags.DoNotWait)

 

Change that to DrawFastFlags.Wait

 

See if that helps. Also, you probably shouldn't be using "Draw Fast". Try using BltFast().

Posted

Flickers in weird colors?? pink light yellow etc?? Try running the app with release and not debug DirectX... Worked for some friend..

 

--Loffen

Erutangis a si tahw
Posted

Flickers with weird colors? In Direct3D (note, not DirectDraw :)), you have to call dxDevice.Clear in order to fix that.

 

BackSurface.ColorFill(Color.Blue) <-- maybe there's a BackSurface.Clear somewhere

-The Pentium Guy

My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!)

vbprogramming.8k.com

My Project (Need VB.NET Programmers)

http://workspaces.gotdotnet.com/ResolutionRPG

Posted (edited)

It doesn�t help. I post the program, maybe someone can figurate it out.

 

So far - it not doing so much, a red rectangle scroll from left to right, then you press right key. The background I very ugly, it base on tiles (32,32) and I have just pick three rectangles (pink, brown and light blue).

Kar.zip

Edited by PlausiblyDamp
Posted

:confused:

 

Maybe it because I use Windows 2000, and try to run it on my Work computer. Licenses and other program creates conflicts.

 

I don�t know, i give up.. :(

 

Thanks anyway.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...