PDA

Click to See Complete Forum and Search --> : Help


Pickleloaf
Feb 1st, 2001, 04:04 AM
I'm making a shooting game (similar to space invaders, Raptor or Tyrian) that makes heavy use of bitblt.

It is essential that your ship is able to constantly change colors during the game. Right now, I just go through all the pixels of a bitmap and use GetPixel and SetPixelV to change the colors. But this slows the game down by heaps, especially on older computers.

I'm thinking that I should pre-draw all the pictures while the game is loading, but I don't know how.

How do I do this? Is there a way for VB to make temporary bitmaps to store pictures? How would I draw to them/load from them/delete them?

kedaman
Feb 1st, 2001, 06:36 AM
There's many ways to store bitmaps in memory, you can load them into stdpictures, have them attached to off screen dc's, or why not even byte arrays, and in directx you can store them in directdrawsurfaces. There's also imagelists but you need to have them all same sized.

If your ship only have a few colors to change to you could predraw all the sequences, in other case you could access each pixel using DMA instead of getpixel/Setpixelv.

Pickleloaf
Feb 2nd, 2001, 12:38 AM
er...y...how?

Pickleloaf
Feb 2nd, 2001, 01:16 AM
Success!
Trial and error pays off

I do this when I'm loading:
I first dim 2 longs, then use CreateCompatibleBitmap and CreateCompatibleDC on them.
Then I use MyPicture = SelectObject(DCname, Bitmapname).
Now I can bitblt to or from MyPicture.

Is this a good way to do it?
Is there a better way?

Pickleloaf
Feb 2nd, 2001, 01:18 AM
Oh, sorry

After I've done this, is there anything I should delete to free up system resources?

kedaman
Feb 2nd, 2001, 03:26 AM
DeleteObject the Bitmap and ReleaseDC the Device context