Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I noticed that the Paint event automatically gives a blank Graphics object, which would mean I'd have to redraw every object in my game (at most 115). There's also an option to set auto backbuffer, right?

 

Obviously the Refresh method and Paint event makes things simplistic an easy, I was wondering just how fast or slow it is? Would I benefit more if I were to just use a single Graphics object and clear moving object by hand (which obviously wouldn't be all 115), or would the speed different in my small game not matter much?

 

Maybe I should take the easy route, and if speed isn't efficient enough, try out the "old fasion" way of creating my own back buffer and just clearing/drawing items that are moving?

 

Oh and btw, how do you set the backbuffer option for a form? :P

Gamer extraordinaire. Programmer wannabe.
  • *Experts*
Posted

Oh and btw, how do you set the backbuffer option for a form? :P

 

You use DoubleBuffering to do that.

Set those properites to true in your form like this:

SetSTyle(ControlStyles.DoubleBuffer, True)
SetStyle(ControlStyles.AllPaintingInWMPaint, True)
SetStyle(ControlStyles.UserPaint, True)

Windows will draw the fastest way possible for it :)

 

As for your object, I think GDI+ will have some trouble drawing 115 objects at one time especially if they are big :)

Posted

You could use Invalidate instead of Refresh. Then you'd only have to redraw the sections that changed.

 

I found this to turn really nasty sometimes because if you stray onto areas that aren't invalidated they just won't show up.

.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Posted

Mutant:

Hmm, I see. Will that still clear the backbuffer on every Paint or will I have to manually clear areas now?

 

BTW objects are only 32x32.

Gamer extraordinaire. Programmer wannabe.
Posted
Hmm, okay. Well I'll try it out, should be able to easily convert it from Paint event to my own routine if redrawing 115 images becomes to much of a slow down. Need to test it anyway, because if it can't handle this then there's no way it'll be able to handle an NES style 2D game.
Gamer extraordinaire. Programmer wannabe.
Posted

advice to to get it faster

 

you might want to change all your mathematical operations to integer because it takes alot of processor usage to perform complex math operations when you have single, double, etc. variables...if you run task manager while you're running your program drag the task manager above the form and look at the processor usage then you'll see! most gaming programmers use this technique to lessen flickering and at the same time processor usage

Posted

You should redraw the entire scene every time, that's just how it's done. Drawing 110 32x32 objects shouldn't slow things down too much, if this is a windowed GDI+ game.

 

Hmm. I was always under the impression that you shouldn't draw any more then you have to (which in 99% of the cases is the entire game). Well any way, good to know drawing 110 objects shouldn't be to big a deal.

Gamer extraordinaire. Programmer wannabe.
  • *Experts*
Posted

Keep in mind that all 3D games are redrawing the entire screen every time - it's not as big a deal as it once was. Back in the "old days", you wanted to use Dirty Rectangles to only update what needed updating because things were much slower to draw.

 

On a game I was working on, I had been drawing roughly 1000 14x14 images using DirectX in fullscreen. My original design had them setup as separate buffers, each drawn through a separate call. The speed was extremely slow (20-30 FPS) on my PIII 700 with GeForce 2 GTS. I modified the code to use one buffer and jumped to 500+ FPS (no waiting on the vsync).

 

Now I know you're not using DirectX, but the point is that there may be different ways to draw things that may speed things up (or slow them down, if done wrong). So I'd test out your theory of drawing 110 objects and see what the speed looks like in a sample app. If it looks ok then you're good to go. If not, you may have to rethink how you design the GUI parts (such as structures to store what's changed and redraw only that).

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

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...