Results 1 to 20 of 20

Thread: FOX's bitblt demo!

  1. #1
    Techi
    Guest

    FOX's bitblt demo!

    see towards end of thread |
    V

    BTW i passed my city and guilds VB module 2 course

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Masks need to be inverted (sprite is black, bg is white) and sprite backgrounds should be black.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    Here is what you did not do to your project.

    VB Code:
    1. Public Sub Draw()
    2. Dim A As Long
    3. Dim b As Long
    4.  
    5. 'Draw the background as below
    6. For A = 0 To Front.Width / Tile.w
    7. For b = 0 To Front.Height / Tile.h
    8. BitBlt BackDC, A * Tile.w, b * Tile.h, Tile.w, Tile.h, Tile.DC, 0, 0, vbSrcCopy
    9. ' above is Copy memory so no mask
    10. Next
    11. Next
    12. ' same but for player
    13. BitBlt BackDC, Player.x, Player.y, Player.w, Player.h, Player.DC, Player.ActAnimation * Player.w * 2 + Player.w, Player.Destination * Player.h, vbSrcPaint
    14. ' above is the mask, draw from animated possition
    15. BitBlt BackDC, Player.x, Player.y, Player.w, Player.h, Player.DC, Player.ActAnimation * Player.w * 2, Player.Destination * Player.h, vbSrcAnd
    16. ' above is destination y position
    17.  
    18. 'copy buffer to screen
    19. BitBlt FrontDC, 0, 0, Front.Width, Front.Height, BackDC, 0, 0, vbSrcCopy
    20. ' **************This is what you need to insert*************************
    21. BitBlt Front, 0, 0, Front.Width, Front.HasDC, FrontDC, 0, 0, vbSrcCopy
    22. ' **************This puts it on the screen******************************
    23. Front.Refresh
    24. End Sub

    You never actually put the stuff on the screen. Everything was ok, except for that.

    Note to Sastraxi:
    His sprites were just fine.

    Anyways Techi you don't even need to put all of what I did into yer project.

    VB Code:
    1. ' Just change this line ...
    2. BitBlt FrontDC, 0, 0, Front.Width, Front.Height, BackDC, 0, 0, vbSrcCopy
    3.  
    4. ' ... to this line.
    5. BitBlt Front.hdc, 0, 0, Front.Width, Front.Height, BackDC, 0, 0, vbSrcCopy

    This way should be faster too because you're eliminating one of the blt steps.

    Now you just need to fix the flicker that's in it and it looks like there's gaps between the tiles. Like everything is skewed. Also, why is the "Front" picboxes height "159.99"? I tried to change it to 160 but it didn't want to change. That's kinda odd.



    Glad to be of service,


    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

  4. #4
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    Here's the zip with the sort of corrected program.
    Attached Files Attached Files
    I see said the blind man as he spat into the wind.

    It all comes back to me now!

    A.D.T.'s VB

  5. #5
    Techi
    Guest

    Thanks!

    Hey your pritty nifty at this.

    with the strange height thing i think it might have to do with the scale hight and width thing.

    i want my project to work like fox's but i dont have vb 6 so not all properties are available (i think ClientHeight is one).

    Thanks i will work on the staitening of my background.

  6. #6
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    No problem.
    I see said the blind man as he spat into the wind.

    It all comes back to me now!

    A.D.T.'s VB

  7. #7
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    I code in VB6 but I don't use any special functions, all projects should run in VB5 too (if you remove the Retained thingy)..

    Anyways, wish you good luck =^_^"

    Here's the corrected function, just copy it over yours:

    Code:
    Public Sub Draw()
        Dim A As Long
        Dim b As Long
        
        'Draw the background as below
        For A = 0 To Front.Width / Tile.w
            For b = 0 To Front.Height / Tile.h
                BitBlt BackDC, A * Tile.w, b * Tile.h, Tile.w, Tile.h, Tile.DC, 0, 0, vbSrcCopy
                'above is Copy memory so no mask
            Next
        Next
        
        ' same but for player
        BitBlt BackDC, Player.x, Player.y, Player.w, Player.h, Player.DC, Player.ActAnimation * Player.w * 2 + Player.w, Player.Destination * Player.h, vbSrcPaint
        ' above is the mask, draw from animated possition
        BitBlt BackDC, Player.x, Player.y, Player.w, Player.h, Player.DC, Player.ActAnimation * Player.w * 2, Player.Destination * Player.h, vbSrcAnd
        ' above is destination y position
        
        'copy buffer to screen
        BitBlt FrontDC, 0, 0, Front.Width, Front.Height, BackDC, 0, 0, vbSrcCopy
        Front.Refresh
    End Sub
    
    'Code improved by vBulletin Tool 2.0
    And btw: The size of your picture is not as you set the size in your code, check the picture (its 129 pixels height which can't be right)..
    Last edited by Fox; Aug 23rd, 2001 at 11:17 PM.

  8. #8
    Techi
    Guest

    Smile New versions

    last night i made the sprite work perfect (bar the flickering) but the problem was the backgroung but drewski claims to have sorted that. ill combine the two tonight.

    do you also program better after a heavy night out or is it just me being a freak again

    ill post the new version 2morrow.

  9. #9
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    The best code I write from 00:00 - 05:00 a.m., I dunno why but it's proven fact I can't think too good during the day, that's why I never have time for real projects

  10. #10
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221

    ScaleMode

    Make sure ALL your scalemodes are 3 - Pixels.
    "1 4m 4 1337 #4xz0r!'
    Janus

  11. #11
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    I got no flickering with this...

    What computer do you have anyways?

    oh and remove this lines:
    Code:
    ' **************This is what you need to insert*************************
    BitBlt Front.hDC, 0, 0, Front.Width, Front.Height, FrontDC, 0, 0, vbSrcCopy
    ' **************This puts it on the screen******************************

  12. #12
    Techi
    Guest

    My PC

    I use a PIII 700mhz, 128 MB SDRAM (but i bought this instead of building it myself from a naff company begining with T ending in y 4 letters)

    oh what the hell....See them

    I also test programs on:

    PII 300MHZ, 64mb ram (1998)
    PI 66MHZ, 32mb ram (1994)

  13. #13
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Well it didnt work before because of this: picFront.Refresh

    You already had the line to copy the back buffer to the front
    picture, but you probably activated AutoRedraw and therefore
    neeeded to refresh the picture so it shows its contents.

    > BitBlt FrontDC, 0, 0, Front.Width, Front.Height, BackDC, 0, 0, vbSrcCopy

    The DC is the handle to that picture, that means it's nothing
    more than a number telling your API where to 'copy' the picture
    to. See the SDK help for more details about Device Contexts..
    oh and: Yes, it is the .hDC property, but it's always faster
    to access a variable than a property
    Last edited by Fox; Aug 27th, 2001 at 02:39 AM.

  14. #14
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221

    Not really...

    hDC's aren't memory addresses; as evidenced by the lower case 'h' they are handles.
    "1 4m 4 1337 #4xz0r!'
    Janus

  15. #15
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Happy now? ^_^

    Read my toturial about DCs for more information..

  16. #16
    Techi
    Guest

    looping a midi

    Hey fox do you know how to loop a midi so it plays without the jumping noise inbetween loops?

  17. #17
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242

    I see now...

    ... so between FrontDC and picFront.hDC there is no difference except for maybe speed. Got it.

    Thanks, I don't use bitblt much anymore. I like DX better
    I see said the blind man as he spat into the wind.

    It all comes back to me now!

    A.D.T.'s VB

  18. #18
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    Hey techi, I fixed your flicker problem. It was flickering because it was switching really quick between different frames of the character's animation. To prevent this I stuck this line in the beginning of your "Animate" subroutine...

    VB Code:
    1. If Player.Animated = False Then Exit Sub

    I think you intended to do this before but I guess you forgot or something.
    Attached Files Attached Files
    I see said the blind man as he spat into the wind.

    It all comes back to me now!

    A.D.T.'s VB

  19. #19
    Techi
    Guest

    Wow!

    Nice one............fox needs to see this because on the older machines i test projects on his went a bit off the rails...just like mine.

    Thanks....cant beleve the thought you must have put into this.

    i know will find out how to loop midis and then i will start to learn tiling.

  20. #20
    Techi
    Guest

    Uh!

    I cannot belive it......does nobody know how to do this!

    can the below file be modified to loop the mid?
    Attached Files Attached Files

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