Nwbish Direct X 7 question...
I am using Visual Basic and trying to make a game...I made a sheet of sprites with the intended "transparent color" to be black...i have a few questions:
1) how do i tell the computer "ONLY RECOGNIZE THIS SPRITE" if it is on the sheet? Someone I know said:
you have to assign a rect shape
and then do rect.top rect.left rect.right and rect.bottom
that tells it what to get from the spriteimage
so does he mean that I need to define the top, bottom, etc. on the pic. or of a shape on the picture or...?
2) how do i make the color black transparent?
Please help...
-Ajain
1) He means the corners of a rect around one frame on the sprite "sheet". For example, if your entire sprite animation is on a 128x128 texture where each frame of animation on this texture is 32x32 lined up left to right, then the rect for frame 1 would be:
2) I never worked with DirectX 7, so I don't know much about DirectDraw. But I think it has something to do with colorkeying. Take a look at the COLORKEY parameter of one of the DirectDraw rendering or blitting functions (or whatever).
rect.top = 0;rect.bottom = 31;rect.left = 0;rect.right = 31;
And rect the rect around frame 2 would be:rect.top = 0;rect.bottom = 31;rect.left = 32;rect.right = 63;
And so on, until you've got one rect for every frame represented on that one sprite "sheet".2) I never worked with DirectX 7, so I don't know much about DirectDraw. But I think it has something to do with colorkeying. Take a look at the COLORKEY parameter of one of the DirectDraw rendering or blitting functions (or whatever).
could u give me a small block of example code (using the same sprite sheet idea thinger u had)?
I'm confused...
do you need to make a shape??
0.o
-Ajain
I'm confused...
do you need to make a shape??
0.o
-Ajain
I can't give you a code example, and tutorials I found on the web are boring.
When you display a sprite, what it actually does it just copying pixels. In order to copy pixels, you need to specify the coordinates and dimension of the source and destination surfaces. Which really mean specifying which part of the image to be copied from and where should it be copied to. This is done by specifying two rectangular areas (RECT), one for source surface, the other for destination surface.
If you still don't understand, search the web for "blit" or "blitting"
Here's from MSDN.
Oh look, GameDev.net dictionary!
When you display a sprite, what it actually does it just copying pixels. In order to copy pixels, you need to specify the coordinates and dimension of the source and destination surfaces. Which really mean specifying which part of the image to be copied from and where should it be copied to. This is done by specifying two rectangular areas (RECT), one for source surface, the other for destination surface.
If you still don't understand, search the web for "blit" or "blitting"
Here's from MSDN.
Oh look, GameDev.net dictionary!
I'm getting truly agrivated at this and am willing to just clip up the sprite sheet in to many different single-sprite sheets...
i have just 1 question
how do u set transparent colors??!
i'll run a few more searches...
-Ajain
i have just 1 question
how do u set transparent colors??!
i'll run a few more searches...
-Ajain
Aparently there isn't (i looked and looked and looked)...so then tell me...is there any way to just set the corner pixels and use that without 12 lines of before-hand coding???
-Ajain
-Ajain
Quote:Original post by Ajain
I'm getting truly agrivated at this and am willing to just clip up the sprite sheet in to many different single-sprite sheets...
i have just 1 question
how do u set transparent colors??!
i'll run a few more searches...
-Ajain
What your looking to do is called color keying in DirectX 7. You need to first get the pixel format, setup a bitmask for the color you want, then set the surfaces color key. I'm not sure how you would do this in VB, but heres some C code which may help you at least find what your looking for.
DWORD KeyColor;DDPIXELFORMAT ddpf;DDCOLORKEY key;// Get the pixel format.ddpf.dwSize = sizeof(ddpf);lpDDSPrimary->GetPixelFormat(&ddpf);// Determine proper key for pixel format.// We will use a pre determined bitmask for Green (0,255,0)KeyColor = ddpf.dwGBitMask;// Set the Low and High Value, then set the surfaces colorkey // passing DDCKEY_SRCBLT indicating that source color keying// will be used, during blitting.key.dwColorSpaceLowValue = KeyColor;key.dwColorSpaceHighValue = KeyColor;dx7surface->SetColorKey(DDCKEY_SRCBLT,&key);
To make your own color key you could do this:
KeyColor = (((DWORD)(ddpf.dwRBitMask * 0.25))&ddpf.dwRBitMask) + (((DWORD)(ddpf.dwGBitMask * 0.50)) & ddpf.dwGBitMask) + (((DWORD)(ddpf.dwBBitMask * 0.75)) & ddpf.dwBBitMask);
Edited by Coder: source tags
[Edited by - Coder on August 4, 2004 2:46:19 PM]
hmm...sounds just a bit above my level...
i am still trying to find a way to blit something w/o having to find/write 12 lines of coding before each object...
is there a way to just jump into it or do u need to do all the preperations first?
if u need to do all preperations b4 each sprite then is there a way i could just write a funciton for it and ifso, where could i find a tutorial that explains it in clear english (i hate tutorials...never was good at them)...
thx
-Ajain
i am still trying to find a way to blit something w/o having to find/write 12 lines of coding before each object...
is there a way to just jump into it or do u need to do all the preperations first?
if u need to do all preperations b4 each sprite then is there a way i could just write a funciton for it and ifso, where could i find a tutorial that explains it in clear english (i hate tutorials...never was good at them)...
thx
-Ajain
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement