• Advertisement

Archived

This topic is now archived and is closed to further replies.

Trouble wilth fades in DD

This topic is 6063 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having trouble executing a fade in Direct Draw. This is the code I am using: PALETTEENTRY pe[COLORS]; for(int i=0; i < COLORS; i++) { Pe.peBlue = 0; Pe[i].peGreen = 0; Pe[i].peRed = 255; lpPrimaryPalette->SetEntries(NULL, i, 1, &Pe[i]); } There are a few problems I am experiencing. 1. The Sprites fade, but the background does not! The sprites are being 'blitted' like this: BltFast( x, y, m_lpDDImage[frame], NULL,DDBLTFAST_SRCCOLORKEY|DDBLTFAST_WAIT); The background is being blitted like this: lpSecondary->BltFast(0,0, lpBackground, NULL, DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); I have a scrolling background, which is also not fading, that I blit using the DBLT_KEYSRC | DDBLT_WAIT flags. I am using transparency--could that be messing the fade up? The transparent color is the same as the background color(black). I don't think this would pose a problem, but maybe. 2. Also, the sprites don't fade gradually. To make them gradually fade I tried code like this: for(int i=0; i < COLORS; i++) { while(Pe[i].peRed < 255 || Pe[i].peBlue > 0 || Pe[i].peGreen > 0) { if(Pe[i].peRed < 255) Pe[i].peRed++; if(Pe[i].peBlue > 0) Pe[i].peBlue--; if(Pe[i].peGreen > 0) Pe[i].peGreen; lpPrimaryPalette->SetEntries(NULL, i, 1, &Pe[i]); } } But this froze my computer. (But I guess it could have just been running so slow that it looked like it froze). Any help would be appreciated. Edited by - CTRL_ALT_DELETE on July 15, 2001 7:02:31 PM

Share this post


Link to post
Share on other sites
Advertisement
Not quite sure about the palette problem, though your while loop looks a bit sus,
Ive had problems with || and > in the same bracket space, try this:


while((Pe[i].peRed < 255) || (Pe[i].peBlue > 0) || (Pe[i].peGreen > 0))



or better still use another for() loop, and loop 256 times making sure you account for any RGB overflow.

  Downloads:  ZeroOne Realm

Edited by - SikCiv on July 15, 2001 11:11:21 PM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I have found some could that makes a nice fade! it is right here--but it will not fade black or white in the background! it fades the other colors, but not black or white! Any ideas?


void fade()
{
PALETTEENTRY pe[COLORS];
lpPrimaryPalette->GetEntries(NULL, 0, COLORS, pe);


for(int n = 0; n < COLORS; n++)
{
for(int i = 0; i < COLORS; i++)
{
if(pe.peRed < 255)
pe[i].peRed++;
if(pe[i].peGreen > 0)
pe[i].peGreen--;
if(pe[i].peBlue > 0)
pe[i].peBlue--;
}
lpPrimaryPalette->SetEntries(NULL, 0, COLORS, pe);
}
}

Share this post


Link to post
Share on other sites
Here is something that is intresting... I was really frustrated about not being able to code a fade function, so I took some DDraw examples out of a book that just basicaly blit a .bmp to the screen, and put my fade function in. The .bmp''s that came with the book faded fine. I even put a black and white streak in them and they still faded. Now, when I copied the entire .bmp image and pasted them into a new blank MSpaint file, and then saved the file, the black and white no longer faded! (I am using MSPaint for all of my graphics). So that seems to be the source of the problem. I still don''t know how to fix it though.

Share this post


Link to post
Share on other sites

  • Advertisement