Results 1 to 6 of 6

Thread: Help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Posts
    13

    Post

    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?

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Posts
    13
    er...y...how?

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Posts
    13

    Smile

    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?

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2001
    Posts
    13
    Oh, sorry

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

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    DeleteObject the Bitmap and ReleaseDC the Device context
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width