Hey,
I'm making a program now where you have lots of "Pets". Each looks different according to it's "PetID" but I only have one "Pet" object for blitting. Therefore my code looks like this:
I have two questions:Code:Private Function PetDraw(i As Integer) 'Call this function to draw Pets 'Assumes that the mask is right of the sprite in the image file 'Frames are square and side-by-side Pet.Picture = LoadPicture(App.Path & "\Images\" & PetID(i) & ".gif") If (PetLeft(i) = False) Then BitBlt Me.hdc, PetX(i), PetY(i), (Pet.Width / 2), Pet.Height, Pet.hdc, (Pet.Width / 2), 0, vbSrcAnd BitBlt Me.hdc, PetX(i), PetY(i), (Pet.Width / 2), Pet.Height, Pet.hdc, 0, 0, vbSrcPaint Else 'Flip Pet (facing LEFT) StretchBlt Me.hdc, PetX(i) + (Pet.Width / 2), PetY(i), -(Pet.Width / 2), Pet.Height, Pet.hdc, (Pet.Width / 2), 0, (Pet.Width / 2), Pet.Height, vbSrcAnd StretchBlt Me.hdc, PetX(i) + (Pet.Width / 2), PetY(i), -(Pet.Width / 2), Pet.Height, Pet.hdc, (Pet.Width / 2), 0, Pet.Width, Pet.Height, vbSrcPaint End If End Function
1) Is this at all efficient, as the line in red changes the Pet object's picture very frequently to draw all the different Pets?
2) Is there a better way of drawing transparent pictures without each image having to have a mask alongside it? I've drawn a lot of Pets and I don't particularly want to go through them adding masks.
Thanks,
- Danjb




Reply With Quote