see towards end of thread |
V
BTW i passed my city and guilds VB module 2 course ;)
Printable View
see towards end of thread |
V
BTW i passed my city and guilds VB module 2 course ;)
Masks need to be inverted (sprite is black, bg is white) and sprite backgrounds should be black.
Here is what you did not do to your project.
VB 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 ' **************This is what you need to insert************************* BitBlt Front, 0, 0, Front.Width, Front.HasDC, FrontDC, 0, 0, vbSrcCopy ' **************This puts it on the screen****************************** Front.Refresh End Sub
You never actually put the stuff on the screen. Everything was ok, except for that.
Note to Sastraxi:
His sprites were just fine. :p
Anyways Techi you don't even need to put all of what I did into yer project.
VB Code:
' Just change this line ... BitBlt FrontDC, 0, 0, Front.Width, Front.Height, BackDC, 0, 0, vbSrcCopy ' ... to this line. BitBlt Front.hdc, 0, 0, Front.Width, Front.Height, BackDC, 0, 0, vbSrcCopy
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
Here's the zip with the sort of corrected program.
Hey your pritty nifty at this.
with the strange height thing i think it might have to do with the scale hight and width thing.
i want my project to work like fox's but i dont have vb 6 so not all properties are available (i think ClientHeight is one).
Thanks i will work on the staitening of my background.
No problem.
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:
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)..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
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 ;)
ill post the new version 2morrow.
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 :(
Make sure ALL your scalemodes are 3 - Pixels.
I got no flickering with this...
What computer do you have anyways?
oh and remove this lines:
Code:' **************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******************************
I use a PIII 700mhz, 128 MB SDRAM (but i bought this instead of building it myself from a naff company begining with T ending in y 4 letters)
oh what the hell....See them
I also test programs on:
PII 300MHZ, 64mb ram (1998)
PI 66MHZ, 32mb ram (1994)
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.
> BitBlt FrontDC, 0, 0, Front.Width, Front.Height, BackDC, 0, 0, vbSrcCopy
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 :)
hDC's aren't memory addresses; as evidenced by the lower case 'h' they are handles.
:)
Happy now? ^_^
Read my toturial about DCs for more information..
Hey fox do you know how to loop a midi so it plays without the jumping noise inbetween loops?
... so between FrontDC and picFront.hDC there is no difference except for maybe speed. Got it.
Thanks, I don't use bitblt much anymore. I like DX better :)
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.
Nice one............fox needs to see this because on the older machines i test projects on his went a bit off the rails...just like mine.
Thanks....cant beleve the thought you must have put into this.
i know will find out how to loop midis and then i will start to learn tiling.
I cannot belive it......does nobody know how to do this!
can the below file be modified to loop the mid?