Results 1 to 6 of 6

Thread: Stop the flicker!!

  1. #1

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544

    Stop the flicker!!

    How can I make my animation stop flicker!!!?!?!?
    Can I do it in the same way as with DDRAW, where all the animations are done on the sec. buffer???
    Could anyone give an example???

    My code:
    VB Code:
    1. Dim MovePic As Integer
    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.  
    6. Private Sub Timer1_Timer()
    7. Me.Cls
    8. 'Draws the mask with vbSrcAnd raster operation
    9. BitBlt Me.hdc, MovePic, 0, picMask.ScaleWidth, picMask.ScaleHeight, picMask.hdc, 0, 0, vbSrcAnd
    10. 'Draws the sprite witht the vbSrcPaint raster operation
    11. BitBlt Me.hdc, MovePic, 0, picSprite.ScaleWidth, picSprite.ScaleHeight, picSprite.hdc, 0, 0, vbSrcPaint
    12.  
    13. End Sub
    14.  
    15. Private Sub Timer2_Timer()
    16. MovePic = MovePic + 2
    17. End Sub
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  2. #2
    Junior Member
    Join Date
    Dec 2001
    Posts
    23

    Do not use a timer

    Hi, why don't you try to do it without a timer. How about:

    Sub_Main()

    Do
    DoEvents

    'Yer code here

    Loop

    End Sub

    And were are you blitting it to? Me.cls make the Form clear. Try making a backbuffer with StretchBlt.

    Hope this helps!

  3. #3
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Try making a backbuffer with StretchBlt.
    ? ? ?

  4. #4
    Junior Member
    Join Date
    Dec 2001
    Posts
    23
    Yes, like this:

    Public Declare Function StretchBlt Lib "gdi32" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long

    this goes into the module

    Then make a picture box and do this in the main loop sub:

    StretchBlt hdc, 0, 0, DispWidth, DispHeight, PB.hdc, 0, 0, 800, 600, vbSrcCopy

    'The DispWidth and DispHeight are just integers.
    like this:

    DispWidth = Screen.Height * 1.315 / Screen.TwipsPerPixelY
    DispHeight = Screen.Height * 0.975 / Screen.TwipsPerPixelY

    From now on, everything you blit, you have to do it on the "PB" picturebox.

    If this doesn't help, wait a bit. I'm writing a tutorial on BitBlt. It will be on my site at www.geocities.com/mman76dev

    Hope this helps!

  5. #5

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    thank you! I'll try it
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  6. #6
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    StrechBlt is crap!

    Ok to answer your question fast, you need a backbuffer indeed. Check out my website/tutorial to learn how

    http://fox.acky.net/vb/

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