Results 1 to 4 of 4

Thread: Newbie code needs help with BitBlt

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Posts
    1

    Question Newbie code needs help with BitBlt

    I am using BitBlt, but only my background is showing up, and not the player's unit (a 'tank')

    no, this isn't ALL the code, but i tried to keep it at a minimum 4 u.

    Here are some things u should know that appear in my code:
    main = form (visible)
    pic = form (invisible)
    mask(0 - 7) = picture boxes
    tank(0 - 7) = picture boxes
    desert = picture box (background image)

    '-------------GLOBAL .BAS CODE----------------------------------------
    Type TypeTank
    X As Integer
    Y As Integer

    Width As Integer
    Height As Integer

    Alive As Integer
    Ammo As Integer
    Score As Integer
    Lives As Integer

    XSpeed As Integer
    YSpeed As Integer
    Direction As Integer
    End Type


    '-------------FORM MAIN CODE------------------------------------------
    Private Sub DrawTank()
    ' Erase old contents
    BitBlt pic.Buffer.hdc, 0, 0, 32, 32, pic.Desert.hdc, Player1.X, Player1.Y, vbSrcCopy

    ' Mask
    BitBlt pic.Buffer.hdc, 0, 0, 32, 32, pic.Mask(Player1.Direction), 0, 0, vbSrcAnd

    ' Fill Mask with tank
    BitBlt pic.Buffer.hdc, 0, 0, 32, 32, pic.Tank(Player1.Direction), 32, 32, vbSrcPaint

    ' Copy buffer to form
    BitBlt main.hdc, Player1.X, Player1.Y, 32, 32, pic.Buffer.hdc, 0, 0, vbSrcCopy
    End Sub
    '----------------------------------------------------------------------------

    Click HERE to email me the answer

    What am i doing wrong?
    It used to work until it got messed somewhere along the line...

    -theplant
    Reply soon

  2. #2
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    Make sure autoredraw is set to true first. Then if that doesn't work try refreshing the picture box.

    Example:

    picBuffer.refresh



    Tell me is this "pic.Buffer.hdc" a mistake? Shouldn't it be "picBuffer.hdc"? You know without the extra period?

    Anyways, I hope this helped.


    Drewski
    I see said the blind man as he spat into the wind.

    It all comes back to me now!

    A.D.T.'s VB

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    Try using OffscreenDC to load your pictures,
    and then BitBlt them into the form!

    Arie.

  4. #4
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    And if you still need help try my tutorial or BitBlt demo

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