Thanks for the tutorial, Teej, this is by far the best on the net. THANKS!
void Game_Main(){ WORD *buffer; long lPitch; DDBLTFX ddbltfx; ZeroMemory(&ddbltfx, sizeof(ddbltfx)); ddbltfx.dwSize = sizeof(ddbltfx); // fill with black ddbltfx.dwFillColor = 0; G.lpDDSBack->Blt(NULL,NULL,NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); DDSURFACEDESC2 ddsd; ZeroMemory(&ddsd, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); // lock surface G.lpDDSBack->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); buffer = (WORD *)ddsd.lpSurface; lPitch = ddsd.lPitch/2; double theta,angle; static double firsttheta=0,bigtheta=0; int x,y,r; static int radius=1; // radius of coloured circles double xcentre; // centre coords of each coloured double ycentre; // circle WORD colour; double tempblue, tempred; int green, red, blue; static int flag=0; // draw three circles 120 degrees apart for (angle=bigtheta; angle<360+bigtheta; angle=angle+120) { // calculate centre coords of each circle xcentre=(100*cos(angle*(3.141/180)))+(SCREEN_WIDTH/2); ycentre=(100*sin(angle*(3.141/180)))+(SCREEN_HEIGHT/2); green=63; tempblue=tempred=31; // draw green section of each coloured circle for (theta=firsttheta+60; theta>firsttheta-1; theta--) { colour=RGB16(0, green, 0); for (r=-radius; r<radius+1; r++) { x=(int) ((r*cos((3.141/180)*theta)) + xcentre); y=(int) ((r*sin((3.141/180)*theta)) + ycentre); buffer[y*lPitch + x]=colour; } // darken green by 1 step every degree green=green-1; } // draw red section of each coloured circle for (theta=firsttheta+180; theta>(firsttheta+120)-1; theta--) { colour=RGB16(red, 0, 0); for (r=-radius; r<radius+1; r++) { x=(int) ((r*cos((3.141/180)*theta)) + xcentre); y=(int) ((r*sin((3.141/180)*theta)) + ycentre); buffer[y*lPitch + x]=colour; } // darken red by 1 step every 2 degrees tempred=tempred-0.5; red=(int)tempred; } // draw blue section of each coloured circle for (theta=firsttheta+300; theta>(firsttheta+240)-1; theta--) { colour=RGB16(0, 0, blue); for (r=-radius; r<radius+1; r++) { x=(int) ((r*cos((3.141/180)*theta)) + xcentre); y=(int) ((r*sin((3.141/180)*theta)) + ycentre); buffer[y*lPitch + x]=colour; } // darken blue by 1 step every 2 degrees tempblue=tempblue-0.5; blue=int(tempblue); } } firsttheta++; // rotate circles clockwise bigtheta--; // rotate entire thing anti-clockwise if (radius>50) flag=1; // maximum radius for each circle, set flag to begin // radius decrease if (flag==0) radius++; else radius--; if (radius<1) // minimum radius for each circle, set radius to 1 and { // set flag to begin radius increase radius=1; flag=0; } // unlock the surface again G.lpDDSBack->Unlock(NULL); // flip backbuffer to primary G.lpDDSPrimary->Flip(NULL, 0);}
Edited by - mirrorman on June 14, 2001 4:19:28 PM
Edited by - mirrorman on June 14, 2001 4:24:26 PM