Sign in to follow this  

Bug in bitblt code

This topic is 4350 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok, this is my first attempt at blitblt, and its been a tad bumpy. But i've gotten through it, and now i have a few things working atm. (very few, actually.) Now the problem is in my animated sprite code. It animates ok. It blits the new image correctly with just one minor problem. Its chopping the end of the image off. (so when you look at the animation, you can see it chop the end off). I can compensate by adjusting my loadsprite paramiters, to make the picturebox i'm blitting from bigger. by why would i need it? This is written in vb6, using bitblit. Download current demo You can move the sprite around through it. Just use the wasd keys. It defaults to moving the object. press C to move the camera, or press P to move the sprite. Proess O again to move the object. As for the blit call. Its in the render() sub.
Public Sub Render()
Dim offset As Integer
Form1.Cls 'Clear the form

For x = 1 To UBound(Sbuff)

If Sbuff(x).pos.x > -Sbuff(x).wid And Sbuff(x).pos.x < Form1.ScaleWidth Then  'Only render something if its on the form
If Sbuff(x).pos.y > -Sbuff(x).hei And Sbuff(x).pos.y < Form1.ScaleHeight Then
    
    offset = Sbuff(x).cframe * Sbuff(x).famo
     
    BitBlt Form1.hdc, Sbuff(x).pos.x, Sbuff(x).pos.y, Sbuff(x).wid, Sbuff(x).hei, Sbuff(x).hdc, offset, 0, vbSrcCopy
    
    Sbuff(x).cframe = Sbuff(x).cframe + 1 'Ok. Possible animated frameset. *crosses fingers*
    If Sbuff(x).cframe > Sbuff(x).fmax Then Sbuff(x).cframe = 0
    
'Blit on the sprites. don't worry, were editing it in vram, before its displayed

End If
End If

Next x



Form1.Refresh
'Get vb to display our sprites
End Sub


I've modified the width (adding offset to it had no real effect), adding an offset to offset didn't change much either. :-( From, Nice coder

Share this post


Link to post
Share on other sites
Well, since you are loading the picture into a PictureBox, you might as well just set AutoSize = true on it and then you won't have to worry about the picture's dimension. You still need to know what size your sprites are though.

Pbuff(0)'s property, AutoSize = true

BTW -- That fixes your problem.

Share this post


Link to post
Share on other sites

This topic is 4350 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this