Bug in bitblt code

Started by
4 comments, last by Nice Coder 18 years, 3 months ago
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
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
Advertisement
*bump*

Has anybody had similar problems before? This is a really wierd problem...
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
What are Sbuff(x).cframe and Sbuff(x).famo?
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)
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
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.
:-D thanks.
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.

This topic is closed to new replies.

Advertisement