This way should be faster too because you're eliminating one of the blt steps.
Now you just need to fix the flicker that's in it and it looks like there's gaps between the tiles. Like everything is skewed. Also, why is the "Front" picboxes height "159.99"? I tried to change it to 160 but it didn't want to change. That's kinda odd.
Glad to be of service,
Drewski
I see said the blind man as he spat into the wind.
I code in VB6 but I don't use any special functions, all projects should run in VB5 too (if you remove the Retained thingy)..
Anyways, wish you good luck =^_^"
Here's the corrected function, just copy it over yours:
Code:
Public Sub Draw()
Dim A As Long
Dim b As Long
'Draw the background as below
For A = 0 To Front.Width / Tile.w
For b = 0 To Front.Height / Tile.h
BitBlt BackDC, A * Tile.w, b * Tile.h, Tile.w, Tile.h, Tile.DC, 0, 0, vbSrcCopy
'above is Copy memory so no mask
Next
Next
' same but for player
BitBlt BackDC, Player.x, Player.y, Player.w, Player.h, Player.DC, Player.ActAnimation * Player.w * 2 + Player.w, Player.Destination * Player.h, vbSrcPaint
' above is the mask, draw from animated possition
BitBlt BackDC, Player.x, Player.y, Player.w, Player.h, Player.DC, Player.ActAnimation * Player.w * 2, Player.Destination * Player.h, vbSrcAnd
' above is destination y position
'copy buffer to screen
BitBlt FrontDC, 0, 0, Front.Width, Front.Height, BackDC, 0, 0, vbSrcCopy
Front.Refresh
End Sub
'Code improved by vBulletin Tool 2.0
And btw: The size of your picture is not as you set the size in your code, check the picture (its 129 pixels height which can't be right)..
last night i made the sprite work perfect (bar the flickering) but the problem was the backgroung but drewski claims to have sorted that. ill combine the two tonight.
do you also program better after a heavy night out or is it just me being a freak again
The best code I write from 00:00 - 05:00 a.m., I dunno why but it's proven fact I can't think too good during the day, that's why I never have time for real projects
' **************This is what you need to insert*************************
BitBlt Front.hDC, 0, 0, Front.Width, Front.Height, FrontDC, 0, 0, vbSrcCopy
' **************This puts it on the screen******************************
Well it didnt work before because of this: picFront.Refresh
You already had the line to copy the back buffer to the front
picture, but you probably activated AutoRedraw and therefore
neeeded to refresh the picture so it shows its contents.
The DC is the handle to that picture, that means it's nothing
more than a number telling your API where to 'copy' the picture
to. See the SDK help for more details about Device Contexts..
oh and: Yes, it is the .hDC property, but it's always faster
to access a variable than a property
Hey techi, I fixed your flicker problem. It was flickering because it was switching really quick between different frames of the character's animation. To prevent this I stuck this line in the beginning of your "Animate" subroutine...
VB Code:
If Player.Animated = False Then Exit Sub
I think you intended to do this before but I guess you forgot or something.
I see said the blind man as he spat into the wind.