Jump to content
  • Advertisement
Sign in to follow this  
Nice Coder

Bug in bitblt code

This topic is 4638 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

'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
sbuff(x).cframe is the current frame. (like frame 0, frame 1, ect.

sbuff(x).famo is the amount it moves in the X direction each frame. (like 64 for a 64 bit wide frame)

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!