Results 1 to 5 of 5

Thread: Bitblt sprites????

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2010
    Posts
    8

    Bitblt sprites????

    Hailo. I'm trying to create sprites using bitblt but have no idea what to do. So far I have used bitblt to create a scrolling background, but I don't think I understand bitblt enough to create, for example, a walking animation.

    So, any good tutorial links/sample code/pseudocode would be great

    Any help would be greatly appreciated.

  2. #2

    Thread Starter
    New Member
    Join Date
    Jul 2010
    Posts
    8

    Re: Bitblt sprites????

    Ok, so no replies yet but I remain hopeful. I found this tutorial on "ZOrder" animation here: http://www.vbforums.com/showthread.php?t=492883

    I was wondering if using bitblt animation would be more efficient, and what the purpose of an image 'mask' is.

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Bitblt sprites????

    You may want to google for tutorials using terms like: sprite mask bitblt
    Here are a couple:
    http://gamemaker.simondonkers.com/tutorial/4
    http://www.rookscape.com/vbgaming/GBeebe/bitblt.php
    http://www.programmers-corner.com/tutorial/45

    Description of BitBlt raster operations: http://www.winprog.org/tutorial/transparency.html

    ZOrder animation almost always has the unwanted effect of flickering.
    Last edited by LaVolpe; Jul 30th, 2010 at 08:55 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2010
    Posts
    8

    Re: Bitblt sprites????

    Thanks for the reply! I have gotten my sprites working, now I'm trying to workout how to move the animation around the screen using the arrow keys. This is my code so far:

    Code:
    Option Explicit
    
    Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
    Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
    
    Dim HeroineY As Integer
    Dim Running As Boolean                                                                  'To know if the game is running
    Const FPS As Double = 61.3                                                              'Frames Per Second
    
    Private Sub Form_Load()
        Me.Show                                                                             'Display main window
        Running = True
        GameLoop                                                                            'Start the loop
    End Sub
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode < 40 Then keyarray(KeyCode) = True 'remember the key is down
    End Sub
    
    Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
        If KeyCode < 40 Then keyarray(KeyCode) = False 'remember the key is up
    End Sub
    
    Private Sub GameLoop()
        Dim cTimer As Currency                                                              'Time of last tick
        Dim cTimer2 As Currency                                                             'Current time
        Dim Freq As Currency                                                                'Frequency of Counter
        Dim Interval As Double 'Time of each frame
        Static animFrame As Integer
        'Dim HeroineY As Integer
        
        
        QueryPerformanceFrequency Freq                                                      'Get Frequency
        Interval = 80
        'Freq / FPS                                                               'Calculate interval based on FPS and Frequency
        
      
    
        
        While Running                                                                       'Start loop
            QueryPerformanceCounter cTimer2                                                 'Get current time
            If cTimer2 >= cTimer + Interval Then                                            'Check if it's time to run code
                Me.Caption = "FPS: " & Format(Round(Freq / (cTimer2 - cTimer), 1), "0.0")   'Display FPS on screen
                QueryPerformanceCounter cTimer                                              'Get time for later use
                
                BitBlt Me.hDC, 0, 0, Me.Width, Me.Height, picBackground.hDC, BGCut, 0, vbSrcCopy
                
                BGCut = BGCut + 5
                
                
                
                Second
                
              'If keyarray(37) = True Then
                
                'HeroineY = HeroineY + 1
                
                BitBlt Form1.hDC, _
                    0, HeroineY, _
                    80, 66, _
                    picSource.hDC, _
                    animFrame * -2, 66, _
                    vbSrcAnd
                    
                BitBlt Form1.hDC, _
                    0, HeroineY, _
                    80, 65, _
                    picSource.hDC, _
                    animFrame * 75, -2, _
                    vbSrcPaint
    
                    animFrame = animFrame + 1
                    If animFrame = 3 Then animFrame = 1
              'End If
               
               
                
                'Enter code here
            End If
            
         
            DoEvents
        Wend
        
    
        
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Running = False                                                                     'Exit loop
    End Sub
    
    Private Sub Second()
        If keyarray(37) = True Then
            HeroineY = HeroineY + 10
        End If
    End Sub
    It's really just a kind of compilation of code I've found from tutorials.

    I've tried many different ways of moving the animation across the screen, besides the one you see here, but either they result in the animation playing in its original spot without movement, or it becomes invisible and all I can see is the scrolling background. Yet if I place in the loop "HeroineY = HeroineY + 10" not in an If statement, the animation moves down the screen.

    Any suggestions would be very much appreciated thank you!

  5. #5
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: Bitblt sprites????

    Actually, i have a sample on that. =D Here it is! I attached it below.
    Attached Files Attached Files
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

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