Results 1 to 24 of 24

Thread: Masking Problem (RESOLVED)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214

    Masking Problem (RESOLVED)

    um what is wrong with my masking code here?

    Code:
    BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgmanmask.hDC, 2, 104, vbSrcAnd
    BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgman.hDC, 2, 104, vbSrcPaint
    it just shows gray around the guy instead of cutting out the white.
    Last edited by jeb2022; Mar 15th, 2003 at 01:10 PM.

  2. #2
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    nothing's wrong with the code so show us the pics too!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    what you mean the actual pictures?, did i color them right?
    Attached Images Attached Images  

  4. #4
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    hmmm....nothing wrong there either...
    did you put the one with the white bg color as mask?
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    yup, the one with the white border is the mask. do i need a backbuffer?

  6. #6
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    it works perfectly fine for me....can you please attach the program?

    this is the only code i used for it:

    VB Code:
    1. Option Explicit
    2. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    3.  
    4.  
    5. Private Sub Picture1_Click()
    6.     BitBlt Picture1.hDC, 0, 0, 50, 50, imgmanmask.hDC, 0, 0, vbSrcAnd
    7.     BitBlt Picture1.hDC, 0, 0, 50, 50, imgman.hDC, 0, 0, vbSrcPaint
    8.     Picture1.Refresh
    9. End Sub
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    this is part of a game so im sure you might have to get rid of some code cause it loads things but here is the form and module that it uses
    Last edited by jeb2022; Mar 13th, 2003 at 04:02 PM.

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Well there is a white "halo" around the guy, and it will only work if the pixel on the sprite is BLACK (with and/paint).
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    well could I use something besides and/paint so that I don't have to go in a paint over that 'halo'

  10. #10
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    sorry, i cant get the program to work....you didnt attach the frx file in the zip and theres probably some other errors inte the code too...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    ya i know there are problems and i forgot the add the module with the map on it, ive got to leave for now but thx for the help

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    my program doesnt appear to be BitBlting the guy over the tiles. Well I can see the guy but the border around it is the color of the picturebox, ive tried changing the color of the picturebox and the border around the gyu changes with it. What do I need to do to fix this

  13. #13
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    421
    Can you attach your program so we can see what's going on?
    [vbcode]
    ' comment
    Rem remark
    [/vbcode]

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    I wish I could but its too big with the tiles.

    here is the code under the keydown

    Code:
      Select Case KeyCode
            Case vbKeyUp ' This makes it so you move up when you press the up key
                look_at = Mid(Map(Char_Y + 1 - 1), Char_X + 1, 1)
                If look_at = "A" Or look_at = "B" Or look_at = "E" Or look_at = "1" Or look_at = "2" Or look_at = "3" Or look_at = "4" Or look_at = "5" Or look_at = "6" Or look_at = "7" Or look_at = "8" Or look_at = "9" Or look_at = "0" Or look_at = "!" Or look_at = "@" Or _
                 look_at = "V" Or look_at = "X" Or look_at = "T" Or look_at = "s" Or look_at = "t" Or look_at = "f" Or look_at = "k" Or look_at = "r" Or look_at = "u" Then
                Char_Y = Char_Y - 1
                Char_Face = 2
                Draw_Position 'Calls a sub
                Draw_Character
                Startup.Caption = "Y = " & Char_Y & " X = " & Char_X 
                End If
    end select
    some of the code for painting tiles

    Code:
    Sub Draw_Position()
    'Draws character on board along with board
    Dim pass As Byte
        For Y = -3 To 10 Step 1 'top to bottom
            For X = -3 To 12 Step 1 'left to right
                pass = 0
                If pass = 0 Then look_at = Mid(Map(Y + Char_Y + 1), (X + Char_X + 1), 1)
                If X = 0 And Y = 0 Then GoTo Skip:
                Select Case look_at
                    
                    Case Is = "A" 'Short Grass
                        BitBlt Picture1.hDC, (X + 3) * 48, (Y + 3) * 48, 48, 48, imgtiles.hDC, 308, 257, vbSrcCopy
    
    end select
    end sub
    last is the code for paintin the guy(this is whats messed up)

    Code:
    Private Sub Draw_Character()
        Select Case Char_Face
        Case Is = 1
                BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgmanmask.hDC, 2, 104, vbSrcAnd
                BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgman.hDC, 2, 104, vbSrcPaint
                Sleep (150)
                BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgmanmask.hDC, 53, 104, vbSrcAnd
                BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgman.hDC, 53, 104, vbSrcPaint
                Sleep (150)
                BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgmanmask.hDC, 104, 104, vbSrcAnd
                BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgman.hDC, 104, 104, vbSrcPaint
                Sleep (150)
    end select
    end sub
    i hope this helps

  15. #15
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    you should set all pics scalemode to 3 (pixels) and autoredraw to true...
    then after blitting you should refresh so the new stuff gets visible..
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    ya ive had that too, it still doesnt want to work.

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    im gonna post it on one of my sites, so just give me a minute then ill put the link here.

  18. #18
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    have you changed this:

    VB Code:
    1. BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgmanmask.hDC, 2, 104, vbSrcAnd
    2.             BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgman.hDC, 2, 104, vbSrcPaint
    3.             Sleep (150)
    4.             BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgmanmask.hDC, 53, 104, vbSrcAnd
    5.             BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgman.hDC, 53, 104, vbSrcPaint
    6.             Sleep (150)
    7.             BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgmanmask.hDC, 104, 104, vbSrcAnd
    8.             BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgman.hDC, 104, 104, vbSrcPaint
    9.             Sleep (150)

    to this:

    VB Code:
    1. BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgmanmask.hDC, 2, 104, vbSrcAnd
    2.             BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgman.hDC, 2, 104, vbSrcPaint
    3.             Picture1.Refresh
    4.             Sleep (150)
    5.             BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgmanmask.hDC, 53, 104, vbSrcAnd
    6.             BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgman.hDC, 53, 104, vbSrcPaint
    7.             Picture1.Refresh
    8.             Sleep (150)
    9.             BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgmanmask.hDC, 104, 104, vbSrcAnd
    10.             BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgman.hDC, 104, 104, vbSrcPaint
    11.             Picture1.Refresh
    12.             Sleep (150)

    ?
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    well here is where the project is http://www.geocities.com/jeb2022/NewFolder.zip

    ya i put picture1.refresh under the keydown code after the draw subs, i also tried it in the draw sub it still didn't work

  20. #20
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    lol!

    If X = 0 And Y = 0 Then GoTo Skip:



    this code is in the loop that draws the bg.....it skips the tile behind the character.....remove that one!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  21. #21
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    after that loop...add: Picture1.Picture = Picture1.Image to get the bg stay even if cls-ing between the animation frames of the character...

    then change all these:

    BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgmanmask.hDC, 2, 104, vbSrcAnd
    BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgman.hDC, 2, 104, vbSrcPaint
    Sleep (150)


    to:

    Picture1.Cls
    BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgmanmask.hDC, 2, 104, vbSrcAnd
    BitBlt Picture1.hDC, 3 * 48, 3 * 48, 48, 48, imgman.hDC, 2, 104, vbSrcPaint
    Picture1.Refresh
    Sleep (150)

    that'll fix some problems...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  22. #22
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    hey....i just made a small tile engine test with smooth scrolling.....try this!
    Attached Files Attached Files
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  23. #23
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    improved the gfx a bit and fixed a few bugs:
    Attached Files Attached Files
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  24. #24

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    THANK YOU SOOOOOOO MUCH
    gawd this thing has been a major pain

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